Re: -[NSSet containsObject:] returns NO when it should return YES
Re: -[NSSet containsObject:] returns NO when it should return YES
- Subject: Re: -[NSSet containsObject:] returns NO when it should return YES
- From: Matt Neuburg <email@hidden>
- Date: Mon, 21 Feb 2011 10:12:28 -0800
On Sat, 19 Feb 2011 17:17:36 -0500, Michael Crawford <email@hidden> 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 fundamental numerics mismatch. The problem is that the 64-bit persistent IDs for iTunes media items are not long long, so reading them with longLongValue will give you the wrong answer. They are *unsigned* long long, which is a different animal.
This matter has been discussed fairly extensively on StackOverflow. My own preference for reading these items is to leave them as NSNumber wherever possible; if I need an alternative representation, I pass them through @"%@" as a string format, which results in a string that does the right thing. See also:
http://stackoverflow.com/questions/1181637/storing-and-retrieving-unsigned-long-long-value-to-from-nsstring
m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings_______________________________________________
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