On Jul 28, 2008, at 3:23 PM, Jean-Daniel Dupas wrote:
Le 29 juil. 08 à 00:09, Charles Steinman a écrit :--- On Mon, 7/28/08, Carter R. Harrison <[EMAIL PROTECTED]> wrote:Actually now that I'm looking at this more closely, NSDictionary is expecting an NSString for the key when inserting a value. Your example uses an NSValue for the key - the compiler is throwing a warning for this one..That's because setValue:forKey: is a KVC method. The NSDictionary method, which accepts any object (though it may prefer strings -- I don't know), is setObject:forKey.Cheers, ChuckWhat about using CFDictionary ? You can create a dicitonary with a callback that support address (NULL for example).
I'll echo this; it's a really handy technique that I use frequently (you can even use integers as keys!).
WARNING: Just in case, there is a major warning here. You should avoid NS/CF bridge when inserting/removing value in a dictionary as the semantic is not the same. NSDictionary always try to copy the key whatever the calback is (or at least did it the last time I try).
Right, -[NSDictionary setObject:forKey:] on a CFDictionary created with a custom retain callback will invoke copyWithZone: before calling your retain callback. Apple claims this is not a bug. Getting/ removing values with objectForKey:/removeObjectForKey: should work, though; if it doesn't, I'd like to know.
-- Adam
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]