• 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: 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

  • Prev by Date: need variable # core model properties for entity
  • Next by Date: Re: How to use Photo Albums of the landscape mode iphone app
  • Previous by thread: Re: -[NSSet containsObject:] returns NO when it should return YES
  • Next by thread: mount .dmg and run file from there
  • Index(es):
    • Date
    • Thread