• 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: coding NSNumber in NSArray?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coding NSNumber in NSArray?


  • Subject: Re: coding NSNumber in NSArray?
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 14 Sep 2009 10:17:30 -0700

On Sep 14, 2009, at 09:11, jon wrote:

I thought i had read that NSNumber knew how to code itself in an NSArray... is this not the case? or is this code below just set up all wrong? and what would the proper way be to set this up?

bookMarkNode's coders are below, this object has the one NSNumber, and two NSStrings....

when i look in the debugger at "allItems", the NSNumber is not well defined.

Well, your question is not very well defined. :)

You don't say specifically what is going wrong. An exception? Missing values? You talk about numbers in an array, but your code doesn't put any numbers in an array (that I can see), and nor do you encode an array (that I can see). If 'allItems' is supposed to be an array of BookMarkNode property values, it makes no sense to put the BookMarkNode itself in there, and IAC you don't show us any code that uses 'allItems', so it's just being leaked.

Whatever your question is, the answer likely is: don't try to use 'encodeObject:forKey:' to encode NSNumber objects. Use one of the variants like "encodeInteger:forKey:" or "encodeInt32:forKey:" -- you need to tell the archiver which *kind* of external representation to use for the number. (Therefore, in your enumerator loops, you'll have to test the class of the value object you're encoding.)


_______________________________________________

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


  • Follow-Ups:
    • Re: coding NSNumber in NSArray?
      • From: Jens Alfke <email@hidden>
References: 
 >coding NSNumber in NSArray? (From: jon <email@hidden>)

  • Prev by Date: Re: Help book content
  • Next by Date: Re: Text Searching system...
  • Previous by thread: Re: coding NSNumber in NSArray?
  • Next by thread: Re: coding NSNumber in NSArray?
  • Index(es):
    • Date
    • Thread