Re: NSMapTable on iOS?
Re: NSMapTable on iOS?
- Subject: Re: NSMapTable on iOS?
- From: Dave Keck <email@hidden>
- Date: Thu, 07 Jul 2011 21:30:35 -1000
> Kind of surprised to discover that NSMapTable doesn’t exist on iOS (even the older procedural form of the API). I need a non-retaining dictionary — do I need to drop down to CFDictionary or is there some higher-level alternative?
I was surprised by this too, but found the CFDictionary alternative palatable:
// weak opaque-pointer keys
// strong object values
NSMutableDictionary *b = (id)CFDictionaryCreateMutable(nil, 0,
nil, &kCFTypeDictionaryValueCallBacks);
// strong object keys
// weak opaque-pointer values
NSMutableDictionary *a = (id)CFDictionaryCreateMutable(nil, 0,
&kCFTypeDictionaryKeyCallBacks, nil);
// weak opaque-pointer keys
// weak opaque-pointer values
NSMutableDictionary *c = (id)CFDictionaryCreateMutable(nil, 0, nil, nil);
Unfortunately the NSMapTable omission means code that's shared between
iOS and OS X can't take advantage of zeroing weak references in the OS
X GC case, but perhaps that's a limited use case.
_______________________________________________
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