Re: Help parsing dictionary integer
Re: Help parsing dictionary integer
- Subject: Re: Help parsing dictionary integer
- From: Eric Brunstad <email@hidden>
- Date: Fri, 10 Jun 2005 16:50:26 -0400
Hi Everyone,
On Jun 10, 2005, at 12:50 PM, Dave DeLong wrote:
That said, I have this line in the dictionary I'm parsing:
<key>Track ID</key><integer>3363</integer>
And this is how I'm trying to grab it (currentTrack is an NSDictionary that contains the information):
NSNumber *tID = [NSNumber numberWithUnsignedInt:[currentTrack objectForKey:@"Track ID"]]; NSString *trackID = [NSString stringWithString:[tID stringValue]]; NSLog(trackID);
Obviously something isn't working right (otherwise I wouldn't be asking a question....). What I'm logging are numbers that are waaaaay too large:
2005-06-10 11:43:13.687 MyApp[729] 68160640
The largest number I should be getting is 3363. Not 68.5 million. What do I need to do to get that integer correctly? (and sorry for a dumb question)
The problem is that [currentTrack objectForKey:@"Track ID"] already returns a NSNumber, not an integer.
First, try NSLog([currentTrack description]) to ensure that the dictionary contains the correct value.
Then, try:
NSNumber *num = [currentTrack objectForKey:@"Track ID"]; NSString *str = [num stringValue]; NSLog(str);
Good Luck,
Eric Brunstad Mind Sprockets Software www.mindsprockets.com
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden