• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [iPhone] NSKeyedArchiver with NSValue Objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iPhone] NSKeyedArchiver with NSValue Objects


  • Subject: Re: [iPhone] NSKeyedArchiver with NSValue Objects
  • From: Waqar Malik <email@hidden>
  • Date: Thu, 24 Dec 2009 12:57:36 -0800

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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >[iPhone] NSKeyedArchiver with NSValue Objects (From: "Henry McGilton (Boulevardier)" <email@hidden>)
 >Re: [iPhone] NSKeyedArchiver with NSValue Objects (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: [iPhone] NSKeyedArchiver with NSValue Objects
  • Next by Date: Re: NSCollectionView NSArrayController bindings from outer hell
  • Previous by thread: Re: [iPhone] NSKeyedArchiver with NSValue Objects
  • Next by thread: Setting the Line Height/ Line Spacing in an NSTextView.
  • Index(es):
    • Date
    • Thread