• 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: NSMapTable on iOS?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSMapTable on iOS?
      • From: James Montgomerie <email@hidden>
References: 
 >NSMapTable on iOS? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: getting last accessed date
  • Next by Date: Re: App Delegate Methods
  • Previous by thread: NSMapTable on iOS?
  • Next by thread: Re: NSMapTable on iOS?
  • Index(es):
    • Date
    • Thread