• 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: Objects as keys NSMutableDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objects as keys NSMutableDictionary


  • Subject: Re: Objects as keys NSMutableDictionary
  • From: Rosyna <email@hidden>
  • Date: Sun, 9 Jul 2006 22:16:50 -0700

No biggy...

NSMutableDictionary* happyDict=[(NSMutableDictionary*)CFDictionaryCrateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) autorelease];

Now you can treat happyDict like any other NSMutableDicitonary and put anything as the keys. Toll free bridging at work.

the default implementation of -hash just returns the pointer value, IIRC, so it's fine to use mutable objects as keys since their pointer value does not change in relation to their content.

Ack, at 7/10/06, email@hidden said:

"Methods that add entries to dictionaries-whether as part of initialization (for all dictionaries) or during modification (for mutable dictionaries)- don't add each value object to the dictionary directly, but copy each key argument and add the copy to the dictionary. In Objective-C, the dictionary copies each key argument (keys must conform to the NSCopying protocol) and adds the copies to the dictionary. Each corresponding value object receives a retain message to ensure that it won't be deallocated before the dictionary is through with it."

--


Sincerely, Rosyna Keller Technical Support/Holy Knight/Always needs a hug

Unsanity: Unsane Tools for Insanely Great People

It's either this, or imagining Phil Schiller in a thong.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Objects as keys NSMutableDictionary
      • From: "Adam R. Maxwell" <email@hidden>
References: 
 >Re: Objects as keys NSMutableDictionary (From: James Bucanek <email@hidden>)
 >Re: Objects as keys NSMutableDictionary (From: email@hidden)

  • Prev by Date: Re: NSTextView drawing over super problem
  • Next by Date: Creating Transparent Window on Dock Icon
  • Previous by thread: Re: Objects as keys NSMutableDictionary
  • Next by thread: Re: Objects as keys NSMutableDictionary
  • Index(es):
    • Date
    • Thread