I had a NSDictionary contains 2 key/value pairs:
NSDictionary *dic = @{@"tag":@2, //NSNumber
@"string":@"someString"}; //NSString
NSLog(@"%i",(int)[dic objectForKey:@"tag"]); //print out 34
NSLog(@"%i",[dic objectForKey:@"tag"] intValue]); //print out 2
Why does "converting id
value to int
with (int)
"get me the wrong result but not the other way? are they in different levels of conversion?