XCode (again) NSDictionary woes...

Joined
Mar 10, 2010
Messages
10
Reaction score
0
Points
1
Location
Burbank, CA
Your Mac's Specs
iMac i5 27" OSX 10.6.2
Hi all,

Nethfel, I hope you catch this. :)

I have a NSDictionary with a handful of info in it represented as string keys and integer values. One item is "Difficulty Level", and it looks like this:
"Difficulty Level" => 2.

When I debug into my code and run "po" in the console, ala:
Code:
po settingsContent

I see:
Code:
"Difficulty Level" => 2

and if I do:
Code:
po [settingsContent objectForKey:@"Difficulty Level"]

I get 2, just as I would expect.

However... when I run the code:
Code:
- (int)difficultyLevel {
	int dl;
	
	if (settingsContent != nil)
		dl = [settingsContent objectForKey:@"Difficulty Level"];
	else
		dl = 0;
	
	return dl;
}

dl is some huge number.

What am I doing wrong??

Thanks!

Chris
 
OP
R
Joined
Mar 10, 2010
Messages
10
Reaction score
0
Points
1
Location
Burbank, CA
Your Mac's Specs
iMac i5 27" OSX 10.6.2
Ack... ok, so I am getting the data from a PList, which has the type declared as "Number," which is returning a reference to a NSNumber.

Adding intValue to the code that pulls the data from the dictionary solved it.

C
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top