Also since you are crossing the boundaries of the framework to UIKit you could also use the NSStringFromCGRect/CGPoint and CGRect/CGPointFromNSString and encoding strings. Again you will have an extras step to go back and forth.
--Waqar On Dec 24, 2009, at 12:47 PM, Quincey Morris wrote: > On Dec 24, 2009, at 09:59, Henry McGilton (Boulevardier) wrote: > >> I bashed into a problem with NSKeyedArchiver trying to encode >> NSValue objects. >> >> I am using NSValue to wrap up CGPoint and CGSize structures, then >> doing an encodeObject: forKey: to encode the NSValue. >> >> I get this message: >> >> [NSKeyedArchiver encodeValueOfObjCType:at:]: this archiver cannot encode >> structs' >> >> I poked around in CocoaBuilder and Google for some definitive answers, but >> the discussions appear to be mostly froth. This seems a little strange, >> as UIKit >> provides a bunch of NSValue additions to encode those CG structs, but the >> NSKeyedArchiver can't encode them. And the message is somewhat >> misleading: >> I'm encoding the NSValue object, not the structure . . . I'm assuming (I >> know, one >> should never assume) that the NSValue object is invoking that >> encodeValueOfObjCType:at: >> message . . . > > NSValue objects are not in suitable for archiving because there's no API > contract that says they'll deal with byte ordering issues for you. (And, in > fact, they couldn't, for structs in general.) > > If you're dealing with NSPoint and NSSize, you can use -[NSKeyedArchiver > encodePoint/Size: forKey:], but you're crossing framework boundaries (a > little bit) with CGPoint and CGSize, so you have an extra step. Either > convert to NSPoint/NSSize and use the matching NSKeyedArchiver method, or > encode the two structure components as numbers. > _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com