• 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: Integer as key in NSMutableDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Integer as key in NSMutableDictionary


  • Subject: Re: Integer as key in NSMutableDictionary
  • From: Jason Foreman <email@hidden>
  • Date: Mon, 4 May 2009 15:38:42 -0500

On May 4, 2009, at 2:22 AM, Weydson Lima wrote:

I am getting warnings when adding integers in the array and assigning
the integer ID as a key. The code does work though, but I am guessing
there is a better way to accomplish what I want. I know that these
methods are expecting pointers as parameters and I am passing a
scalar. So, what's the best way to approach that?

Actually, as the documentation specifies, setObject:forKey: expects an object that conforms to the NSCopying protocol as the key parameter. Keys are copied when objects are inserted.


You could use an NSNumber, e.g.:

[result setObject:... forKey:[NSNumber numberWithInt:ID]];


Jason

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: 
 >Integer as key in NSMutableDictionary (From: Weydson Lima <email@hidden>)

  • Prev by Date: Re: Writable dir for non-admin user outside user's dir
  • Next by Date: Re: Problem with the list?
  • Previous by thread: Integer as key in NSMutableDictionary
  • Next by thread: Re: Integer as key in NSMutableDictionary
  • Index(es):
    • Date
    • Thread