I’m using an NSMapTable object with weak value references, in an ARC-based 
target. Unfortunately I’ve been told that this code crashes on OS X 10.7 — 
initializing the table raises an exception "Requested configuration not 
supported.” I’ve tried adjusting the option flags but without success. Is there 
a way to make this work, or does NSMapTable just not support ARC-based weak 
references in 10.7?

More detail: Here’s the code I’ve been using:

        _map = [[NSMapTable alloc] initWithKeyOptions: 
NSPointerFunctionsStrongMemory |
                                                       
NSPointerFunctionsObjectPersonality
                                         valueOptions: 
NSPointerFunctionsWeakMemory |
                                                       
NSPointerFunctionsObjectPersonality
                                             capacity: 100];

On re-reading the docs yesterday, I saw that one is not supposed to use 
NSPointerFunctions flags with NSMapTable, so I changed the code to

        _map = [[NSMapTable alloc] initWithKeyOptions: NSMapTableStrongMemory
                                         valueOptions: NSMapTableWeakMemory
                                             capacity: 100];

which doesn’t work either; and I noticed that NSMapTableWeakMemory was only 
added in 10.8. It replaces a similar NSMapTableZeroingWeakMemory constant, but 
the docs say this "uses GC weak read and write barriers, and dangling pointer 
behavior otherwise”, which implies it doesn’t work correctly with ARC.

—Jens
_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to