• 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: -[NSSet containsObject:] returns NO when it should return YES
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -[NSSet containsObject:] returns NO when it should return YES


  • Subject: Re: -[NSSet containsObject:] returns NO when it should return YES
  • From: Andy Lee <email@hidden>
  • Date: Sat, 19 Feb 2011 22:08:44 -0500

On Feb 19, 2011, at 6:08 PM, Andy Lee wrote:
> I just did a quick test and confirmed that you do get two different instances with the same hash, but they are in face isEqual: to each other and hence their presence in a set is detected, as I would expect.
>
>   NSNumber *one = [NSNumber numberWithLongLong:1];
>   NSNumber *another = [NSNumber numberWithLongLong:1];
>   NSSet *set = [NSSet setWithObject:another];
>
>   NSLog(@"+++ one %p, hash = %ld -- another %p, hash = %ld -- is eq = %d, contains one = %d, contains another = %d",
>         one, [one hash], another, [another hash], [one isEqual:another], [set containsObject:one], [set containsObject:another]);

Whoops, actually I got the same instance using 1, presumably because NSNumber keeps a few low number instances cached. What I said above is true if I retry with 123456789.

--Andy

_______________________________________________

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

References: 
 >-[NSSet containsObject:] returns NO when it should return YES (From: Michael Crawford <email@hidden>)
 >Re: -[NSSet containsObject:] returns NO when it should return YES (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: -[NSSet containsObject:] returns NO when it should return YES
  • Next by Date: Re: -[NSSet containsObject:] returns NO when it should return YES
  • Previous by thread: Re: -[NSSet containsObject:] returns NO when it should return YES
  • Next by thread: Re: -[NSSet containsObject:] returns NO when it should return YES
  • Index(es):
    • Date
    • Thread