views:

22

answers:

1

Hello,

I'm writing some Cocoa code and having trouble with the iTunes track persistent IDs returned by Scripting Bridge and Distributed Notifications.

Taking one track as an example - in a Scripting Bridge call I get the following values:

Persistent ID: 2FBA59E028DC5E51 (NSString) - Hexadecimal?

...but from a Distributed Notification for the same track I get the following values:

Persistent ID: 3439160084743872081 (NSString)

Can anyone help me to get the two values match up?

Thanks

+1  A: 

The first ID is indeed the same number as the second. The first is encoded as hexadecimal, and the second as decimal. Simply convert these to an int64 and you'll be able to compare them directly.

You can use the strtoll() function to do the conversion. See man strtoll for usage information. Since you're starting with NSString values, you can get the C string equivalent using [str UTF8String].

Kaelin Colclasure
Thanks. Could you give me an example of how to do that? Do I use NSScanner?
Thanks. I've got it now. For anyone else reading this who is coding Cocoa without a good understanding of C, learn it!