• 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: Help parsing dictionary integer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
email@hidden
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

References: 
 >Help parsing dictionary integer (From: Dave DeLong <email@hidden>)

  • Prev by Date: Re: Still can't figure out this overrelease bug
  • Next by Date: Re: Am I overreleasing something?
  • Previous by thread: Re: Help parsing dictionary integer
  • Next by thread: Appending to text file... best way?
  • Index(es):
    • Date
    • Thread