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

Re: Re: Objects as keys NSMutableDictionary


  • Subject: Re: Re: Objects as keys NSMutableDictionary
  • From: "Michael Ash" <email@hidden>
  • Date: Mon, 10 Jul 2006 13:32:38 -0400

On 7/10/06, Adam Maxwell <email@hidden> wrote:

On Monday, July 10, 2006, at 07:19AM, Rosyna <email@hidden> wrote:

>Well, if it assumed the keys were always strings, then it would just
>use kCFCopyStringDictionaryKeyCallBacks when creating the internal
>CFDictionary. In which case this would make the copyWithZone: a
>useless extra step. It's also why I mistakenly assumed that creating
>the NSDictionary with the CF call using different callbacks would
>address this issue.

It's an inconsistent situation (at least in my view), since the dictionary /will/ use any custom retain/release/equal/hash callbacks you define (so using objectForKey: works fine, and uses pointer equality), but setObject:forKey: will first create a copy...and the copy is then retained using your custom retain callback.

Of course, if you use the CF functions, only the callbacks are used, so it's easy to make a KVC-compliant wrapper for it. I used it to make an NSCountedSet subclass that uses case-insensitive string comparison and stores integers directly in the dictionary; very handy.

In case anybody is wondering, Apple believes that none of this is wrong. I just noticed an update to my original bug (4350677) filed on this. The followup states:

"Engineering has determined that this issue behaves as intended based
on the following information:

"Please note that the callbacks are still respected, however,
-[NSMutableDictionary setObject:forKey:] is documented to copy the
key."

So I guess incorrect behavior still wins because The Docs Said So.

I'm done with this particular battle, it's just not that important. If
anybody else wants to take it up with Apple, though, feel free.

Mike
_______________________________________________
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


References: 
 >Re: Objects as keys NSMutableDictionary (From: email@hidden)
 >Re: Objects as keys NSMutableDictionary (From: "Adam R. Maxwell" <email@hidden>)
 >Re: Objects as keys NSMutableDictionary (From: "Adam R. Maxwell" <email@hidden>)
 >Re: Objects as keys NSMutableDictionary (From: Adam Maxwell <email@hidden>)

  • Prev by Date: Re: NSData to NSString encoding error
  • Next by Date: Re: convert Java or C Source code into Objective-c
  • Previous by thread: Re: Objects as keys NSMutableDictionary
  • Next by thread: Re: Re: Objects as keys NSMutableDictionary
  • Index(es):
    • Date
    • Thread