• 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: Weydson Lima <email@hidden>
  • Date: Tue, 5 May 2009 00:52:45 -0500

Thanks all for the replies. I clearly understand now that I should use
NSNumber instead of NSInteger. However, another question came up: when I use
the removeObjectForKey, how can I make a reference to a specific key? Let's
say I want to remove key that was initialized with [NSNumber
numberWithInt:1]. If I call removeObjectForKey:[NSNumber numberWithInt:1],
that method won't work because a new NSNumber pointer is being created,
correct?The only solution I could find is to use enumeration and go through
each key and gets its integer value.

Thank you

On Mon, May 4, 2009 at 6:24 PM, Jean-Daniel Dupas <email@hidden>wrote:

>
> Le 4 mai 09 à 22:58, Alexander Heinz a écrit :
>
>  On May 4, 2009, at 3:22 AM, Weydson Lima wrote:
>>
>>> 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?
>>>
>>
>> That's correct. You really shouldn't put any scalar types in an
>> NSDictionary (or any other container type in the Cocoa API.)
>>
>
> Not quite true. NSHashTable and NSMapTable are part of Cocoa API and are
> design to support NSInteger directly.
>
> _______________________________________________
>
> 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
>
_______________________________________________

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: Integer as key in NSMutableDictionary
      • From: Nick Zitzmann <email@hidden>
    • Re: Integer as key in NSMutableDictionary
      • From: Jonathan Hess <email@hidden>
References: 
 >Integer as key in NSMutableDictionary (From: Weydson Lima <email@hidden>)
 >Re: Integer as key in NSMutableDictionary (From: Alexander Heinz <email@hidden>)
 >Re: Integer as key in NSMutableDictionary (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Correct memory management in -awakeAfterUsingCoder: ?
  • Next by Date: Re: Correct memory management in -awakeAfterUsingCoder: ?
  • Previous by thread: Re: Integer as key in NSMutableDictionary
  • Next by thread: Re: Integer as key in NSMutableDictionary
  • Index(es):
    • Date
    • Thread