FROM : Michael Ash
DATE : Sat May 13 23:16:23 2006
On 5/13/06, Adam R. Maxwell <<email_removed>> wrote:
>
> Another way to do this might be to create a CFMutableDictionary with
> custom callbacks that retain keys instead of copying them, and
> compares keys based on pointer equality; with toll-free bridging,
> you'd just treat it as a standard NSMutableDictionary. You have to
> ensure that the hash of the keys (NSImage instances) doesn't change
> while they're in the dictionary, though.
Sadly, this doesn't work. While you can indeed treat such a
CFMutableDictionary as an NSMutableDictionary, the Cocoa methods will
not respect your custom callbacks. In other words, if you create a
CFMutableDictionary which does not copy its keys, then do [myCFDict
setObject:obj forKey:key], key *will* be copied.
I consider this a bug and have filed it as rdar://4350677 . The
obvious workaround is to use the actual CF functions instead, which is
not really a problem.
Mike
DATE : Sat May 13 23:16:23 2006
On 5/13/06, Adam R. Maxwell <<email_removed>> wrote:
>
> Another way to do this might be to create a CFMutableDictionary with
> custom callbacks that retain keys instead of copying them, and
> compares keys based on pointer equality; with toll-free bridging,
> you'd just treat it as a standard NSMutableDictionary. You have to
> ensure that the hash of the keys (NSImage instances) doesn't change
> while they're in the dictionary, though.
Sadly, this doesn't work. While you can indeed treat such a
CFMutableDictionary as an NSMutableDictionary, the Cocoa methods will
not respect your custom callbacks. In other words, if you create a
CFMutableDictionary which does not copy its keys, then do [myCFDict
setObject:obj forKey:key], key *will* be copied.
I consider this a bug and have filed it as rdar://4350677 . The
obvious workaround is to use the actual CF functions instead, which is
not really a problem.
Mike
| Related mails | Author | Date |
|---|---|---|
| Lawrence Sanbourne | May 13, 08:24 | |
| Andrew Bowman | May 13, 08:40 | |
| Greg Hurrell | May 13, 10:29 | |
| Pontus Ilbring | May 13, 13:32 | |
| Lawrence Sanbourne | May 13, 17:51 | |
| Adam R. Maxwell | May 13, 18:19 | |
| Michael Ash | May 13, 23:16 | |
| Sherm Pendley | May 13, 23:32 | |
| Adam R. Maxwell | May 14, 09:12 |






Cocoa mail archive

