• 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: Why can't I use any object as a key in a dictionary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why can't I use any object as a key in a dictionary?


  • Subject: Re: Why can't I use any object as a key in a dictionary?
  • From: Rick Mann <email@hidden>
  • Date: Mon, 1 Feb 2010 00:12:49 -0800

On Feb 1, 2010, at 00:10:11, Roland King wrote:

> Because NSDictionary requires keys to be copyable because it copies them (it's in the documentation). Use a CFDictionary() instead, you can set it up to retain the keys and do what you want.

Oh! I thought NSDictionary and CFDictionary were the same thing under the hood.

>
> Rick Mann wrote:
>> I'd like to use a CALayer object as a key in a dictionary. The reason is that when my app detects a hit in a layer, I need to quickly determine which object I've associated with it. Since I can't store a reference to an arbitrary object in the CALayer, a dictionary seems to be the most expedient way to do that.
>> Unfortunately, I can't seem to add my layer as the key (it fails with "-[CALayer copyWithZone:]: unrecognized selector sent to instance 0x50132a0"). It's really pretty handy to be able to use any object as a key, why is this not the case in Obj-C?
>> TIA,
>> Rick
>> _______________________________________________
>> 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

References: 
 >Why can't I use any object as a key in a dictionary? (From: Rick Mann <email@hidden>)
 >Re: Why can't I use any object as a key in a dictionary? (From: Roland King <email@hidden>)

  • Prev by Date: Re: Why can't I use any object as a key in a dictionary?
  • Next by Date: Re: NSDocument "save as" bug
  • Previous by thread: Re: Why can't I use any object as a key in a dictionary?
  • Next by thread: Re: Why can't I use any object as a key in a dictionary?
  • Index(es):
    • Date
    • Thread