views:

112

answers:

2

here is my plist and code

> <plist version="1.0">
>     <dict>
>      <key>Title</key>
>      <string>News</string>
>      <key>icon</key>
>      <integer>0</integer>
>     </dict>
>     </plist>




int i = [dictionary objectForKey:@"icon"];
NSLog(@"%d",i);

log result is 81841904 why it not 0 ?

+3  A: 

objedctForKey returns a reference, not an integer. I believe that it's returning a NSNumber in this case. You can get an integer value out of that.

Corey Porter
which function that i can use to get NSNumber?thanks for you advise Corey Porter
RAGOpoR
+3  A: 

Corey is correct. Note the word "object" in the -objectForKey: method; in this case, that'll indeed be an NSNumber. What you should be doing is

 int i = [[dictionary objectForKey:@"icon"] intValue];
Noah Witherspoon
Thank Noah Witherspoon
RAGOpoR