Results 1 to 2 of 2
  1. #1
    XCode (again) NSDictionary woes...

    Member Since
    Mar 10, 2010
    Location
    Burbank, CA
    Posts
    10
    Specs:
    iMac i5 27" OSX 10.6.2
    XCode (again) NSDictionary woes...
    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

  2. #2
    XCode (again) NSDictionary woes...

    Member Since
    Mar 10, 2010
    Location
    Burbank, CA
    Posts
    10
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. NSDictionary doesn't work
    By TikaSoftware in forum OS X - Development and Darwin
    Replies: 5
    Last Post: 03-22-2015, 01:04 PM
  2. NSDictionary doesn't work
    By TikaSoftware in forum OS X - Apps and Games
    Replies: 0
    Last Post: 03-22-2015, 11:17 AM
  3. About the questions of NSDictionary
    By copperybean in forum iOS Development
    Replies: 2
    Last Post: 05-30-2012, 08:59 PM
  4. Xcode stopped letting me run Xcode app on iPad
    By ildsarria in forum iOS Development
    Replies: 1
    Last Post: 11-09-2011, 03:15 PM
  5. NSDictionary iteration
    By khaleed in forum iOS Development
    Replies: 1
    Last Post: 08-26-2011, 10:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •