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

2011-03-04 Thread Michael Crawford
Creating the NSNumber objects using unsignedLongLong instead of longLong solved my problem. Thanks to everyone who participated in the lively discussion. Sorry for being a little slow in closing the loop. -Michael On Feb 21, 2011, at 9:50 PM, Wim Lewis wrote: > > On 19 Feb 2011, at 2:17 PM,

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

2011-02-21 Thread Wim Lewis
On 19 Feb 2011, at 2:17 PM, Michael Crawford wrote: > Anyone have previous experience with this problem? Can you shed some light > on where my thinking and assumptions are wrong. I could write a sweet of > tests to try and prove/disprove what I think is happening but I'm hoping to > benefit f

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

2011-02-21 Thread Matt Neuburg
On Sat, 19 Feb 2011 17:17:36 -0500, Michael Crawford said: >I'm trying to compare instances of NSNumber using NSSet. I have a set of >numbers, which represent 64-bit persistent IDs for iTunes media-items. I >access these values using the -[NSNumber longLongValue] method. You're having a fund

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

2011-02-19 Thread Greg Guerin
Michael Crawford wrote: The following gdb console output demonstrates an instance of a media-item persistent-ID property that, when queried gives a large unsigned number. When I ask again using the -longLongValue method, I get the answer I was expecting. When I look inside the set, you

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

2011-02-19 Thread Andy Lee
Ah, thanks. That's here: I was only looking at the NSSet docs. --Andy On Feb 20, 2011, at 1:03 AM, Roland King wrote: > > On 20-Feb-2011, at 1:54 PM, Andy Lee wrote: > >> >> One thing I'

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

2011-02-19 Thread Roland King
On 20-Feb-2011, at 1:54 PM, Andy Lee wrote: > > One thing I'm puzzled about is that NSSet does not copy its entries the way > NSDictionary copies its keys. This is implied by the member: documentation > quoted earlier: > > "If the set contains an object equal to object (as determined by isEqu

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

2011-02-19 Thread Andy Lee
On Feb 19, 2011, at 10:31 PM, Ken Thomases wrote: > On Feb 19, 2011, at 9:26 PM, Quincey Morris wrote: > >> On Feb 19, 2011, at 19:06, Kyle Sluder wrote: >> >>> Your experience indicates that -containsObject: uses pointer identity, >>> whereas -member: uses -isEqual:. >> >> What's especially c

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

2011-02-19 Thread Ken Thomases
On Feb 19, 2011, at 9:26 PM, Quincey Morris wrote: > On Feb 19, 2011, at 19:06, Kyle Sluder wrote: > >> Your experience indicates that -containsObject: uses pointer identity, >> whereas -member: uses -isEqual:. > > What's especially confusing is that -[NSArray containsObject:] is documented >

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

2011-02-19 Thread Quincey Morris
On Feb 19, 2011, at 19:06, Kyle Sluder wrote: > On Feb 19, 2011, at 7:01 PM, Michael Crawford wrote: > >> >> I assumed this is the case because regardless of whether or not you call >> -boolValue or -longLongValue, -hash returns the same result. I've already >> shown that they do indeed cont

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

2011-02-19 Thread Ken Thomases
On Feb 19, 2011, at 9:01 PM, Michael Crawford wrote: > On Feb 19, 2011, at 9:31 PM, Ken Thomases wrote: > >> On Feb 19, 2011, at 4:17 PM, Michael Crawford wrote: >> >>> I also assumed that whether or not the value is signed or unsigned; >>> negative or positive makes no difference as long as ca

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

2011-02-19 Thread Andy Lee
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 numbe

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

2011-02-19 Thread Kyle Sluder
On Feb 19, 2011, at 7:01 PM, Michael Crawford wrote: > > I assumed this is the case because regardless of whether or not you call > -boolValue or -longLongValue, -hash returns the same result. I've already > shown that they do indeed contain the same value, when -longLongValue is > called on

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

2011-02-19 Thread Michael Crawford
On Feb 19, 2011, at 9:31 PM, Ken Thomases wrote: > On Feb 19, 2011, at 4:17 PM, Michael Crawford wrote: > >> I also assumed that whether or not the value is signed or unsigned; negative >> or positive makes no difference as long as calling the same accessor method >> on both NSNumber instances

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

2011-02-19 Thread Ken Thomases
On Feb 19, 2011, at 4:17 PM, Michael Crawford wrote: > I also assumed that whether or not the value is signed or unsigned; negative > or positive makes no difference as long as calling the same accessor method > on both NSNumber instances returns the same result. I think this is wrong. I can't

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

2011-02-19 Thread Andy Lee
On Feb 19, 2011, at 5:17 PM, Michael Crawford wrote: > When I look inside the set, you will see that the value -1748299021286640132 > is in the set. However, when -containsObject is called, it returns NO. Are you sure the objects you are dealing with are always NSNumbers? If one of them is an N

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

2011-02-19 Thread Jim Correia
On Feb 19, 2011, at 2:17 PM, Michael Crawford wrote: > I'm trying to compare instances of NSNumber using NSSet. I have a set of > numbers, which represent 64-bit persistent IDs for iTunes media-items. I > access these values using the -[NSNumber longLongValue] method. I'm adding > them to an

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

2011-02-19 Thread Scott Ribe
On Feb 19, 2011, at 3:17 PM, Michael Crawford wrote: > I assumed that the -[NSObject hash] method is used to determining equality > and that to different NSNumber instances will hash out to the same value if > they have the same 64-bit value stored inside. I'm pretty sure that, for instance, tw

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

2011-02-19 Thread Michael Crawford
I'm trying to compare instances of NSNumber using NSSet. I have a set of numbers, which represent 64-bit persistent IDs for iTunes media-items. I access these values using the -[NSNumber longLongValue] method. I'm adding them to an instance of NSSet and then use that instance to determine whe