• 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: Simple NSMutableDictionary problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple NSMutableDictionary problem


  • Subject: Re: Simple NSMutableDictionary problem
  • From: Gregory Weston <email@hidden>
  • Date: Tue, 12 Aug 2008 18:21:30 -0400

Matt Keyes wrote:

How do I have an int as a value in a NSMutableDictionary object?

By wrapping it in an NSNumber.

It seems like (b/c the type is "id" for the first param) that NSMutableDictionary wants a pointer. Well, how do I give it just a plain integer copy without having the compiler yell at me? I have been banging my head on my desk over this silly little thing.

You don't. The keys and values for NSDictionary are objects.

Also, how do I define a non-mutable dictionary of a particular size? There is no dictionaryWithCapacity function that I can find in the non-mutable version. All the examples I can find are not practical (i.e. hardcoding a dictionary at its creation with random values like @"One", @"Two", etc.).

Um. What are you really trying to accomplish? What would it mean to allocate a non-mutable dictionary with the capacity for 3 objects which could never be set? What would you do with such a thing? Notice that the capacity argument in the NSMutableDictionary factory doesn't define a hard limit; it defines an initial capacity to optimize initial memory allocation. So it doesn't really give you "a 3-slot dictionary" or something like that.


_______________________________________________

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


  • Prev by Date: Re: Cocoa-dev Digest, Vol 5, Issue 1446
  • Next by Date: Re: Opening an external file in a external application
  • Previous by thread: Re: Simple NSMutableDictionary problem
  • Next by thread: [Meet]: LA CocoaHeads Thursday August 14th, 7:30pm
  • Index(es):
    • Date
    • Thread