• 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: CFMutableDictionary vs. NSMapTable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFMutableDictionary vs. NSMapTable


  • Subject: Re: CFMutableDictionary vs. NSMapTable
  • From: Mike Shields <email@hidden>
  • Date: Mon, 9 Sep 2002 17:13:47 -0600

On Monday, September 9, 2002, at 07:25 AM, Bill Bumgarner wrote:

I need to create a set of maps between integer keys and either objects or integer values, depending on context (though any one given dictionary/map will only have values of a single type, obviously).

I have long used NSMapTable's API in this context, but was curious if CFDictionary's API is now preferable. Looking further at CFDictionary, it doesn't explicitly document a case where a non-CFTypeRef is used as the key or values. At the same time, the key and value callback functions appear to do what is needed to use integer key/values if you simply pass in NULL for the structure references.

Right. The NULL values for retain/release are exactly what you're looking for. You'd probably also want to add in a custom hash and equal callback to be 100% safe from all edge cases.

However, given that the fact that the number of bits in an (int) is only coincidentally the same as the number of bits in (void *) -- (void *) being the type of all key and value parameters to the CFDictionary APIs -- it would appear that CFDictionary is very explicitly only designed to handle pointer types.

Is there some reason that you need to use ints explicitly? And in my copy of the Foundation docs, NSMapInsert, NSMapGet, etc all take void* also. So where's the difficulty of switching?

As such, I'm sticking with NSMapTable.

Correct line of thinking or did I miss something?


Not correcting, but just a little confused.

Mike
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: CFMutableDictionary vs. NSMapTable
      • From: Bill Bumgarner <email@hidden>
References: 
 >CFMutableDictionary vs. NSMapTable (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: (newbie)RE: Book- Building cocoa applications..
  • Next by Date: Build Errors
  • Previous by thread: CFMutableDictionary vs. NSMapTable
  • Next by thread: Re: CFMutableDictionary vs. NSMapTable
  • Index(es):
    • Date
    • Thread