• 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 with C strings as keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMapTable with C strings as keys


  • Subject: Re: NSMapTable with C strings as keys
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 27 May 2013 23:08:03 -0700

On May 27, 2013, at 10:46 PM, Oleg Krupnov <email@hidden> wrote:

> Now, the problem is that sometimes when I try to get a value from the
> table, the MapTableKeyComparator function is not called at all, and
> NSMapGet returns NULL, thought immediate dump of the table shows that
> all previous records are perfectly present in the table.

Probably because you haven’t implemented a hash function, only an equals function. I’m guessing NSMapTable’s default hash function merely hashes the key pointer itself, which means that if you pass it a different pointer to an equal C string, it won’t find anything.

—Jens

_______________________________________________

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 with C strings as keys
      • From: Oleg Krupnov <email@hidden>
References: 
 >NSMapTable with C strings as keys (From: Oleg Krupnov <email@hidden>)

  • Prev by Date: NSMapTable with C strings as keys
  • Next by Date: Re: NSMapTable with C strings as keys
  • Previous by thread: NSMapTable with C strings as keys
  • Next by thread: Re: NSMapTable with C strings as keys
  • Index(es):
    • Date
    • Thread