A very naïve suggestion is that if you are targeting OS X you might be able to use HTML or RTF. Save that and convert the stored into to an attributed string at run time.
One idea of font descriptors is that a particular font may not exist on a particular computer, but similar ones might be available. When the end result is created as an attributed string that info is already lost. On Feb 27, 2012, at 14:33, Heath Borders <heath.bord...@gmail.com> wrote: > I don’t know of an easy workaround. Back in the day I would have suggested > creating a category on CGColor that adds the required archiving methods, > but doing this will get you rejected from the App Store. You may need to > write a function that walks through a mutable attributed string and finds > all color objects and replaces them with something serializable, and > another function that reverses this. > > > How do you create a category for a Foundation type that isn't an > Objective-C class? And why would that get you rejected? > > Sent from my iPad > > On Feb 27, 2012, at 12:21 AM, Jens Alfke <j...@mooseyard.com> wrote: > > > On Feb 26, 2012, at 9:44 PM, Michael Swan wrote: > > the thing that doesn't make any sense is that if NSAttributedString > conforms to the NSCoding protocol it must be able to fully pack itself up > when encodeWithCoder: is called on it which means that it should already be > taking care of encoding the CGColor in whatever way necessary. > > > Archiving doesn’t work that way. Every object asks its instance variables > to archive themselves; it’s not in charge of how they do it. > NSAttributedString is, basically, an array of dictionaries, each of which > can have arbitrary values in it. NSAttributedString itself doesn’t know or > care what those keys or values are. (Note that NSAttributedString is > implemented in the Foundation framework, which is lower level than UIKit.) > > What you’re running into is that CGColor isn’t archivable — it doesn’t > implement the protocol methods like -encodeWithCoder:. So the attributed > string is asking the attribute dictionary to archive itself, and the > dictionary asks its keys and values to archive themselves, and the CGColor > object fails. > > I don’t know of an easy workaround. Back in the day I would have suggested > creating a category on CGColor that adds the required archiving methods, > but doing this will get you rejected from the App Store. You may need to > write a function that walks through a mutable attributed string and finds > all color objects and replaces them with something serializable, and > another function that reverses this. > > —Jens > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com > > This email sent to heath.bord...@gmail.com > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/ev%40monoceroi.com > > This email sent to e...@monoceroi.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com