Search code examples
iphoneiostouchjson

get touchJson data for int type


I am using touchJson to deserialize my json from server. My json is like below:

{"text":"abc", "user_id":12345}

After deserializing, I use below code to get the Json values:

NSString *text = [dict objectForKey:@"text"];

This is simple because the data is string, but for "user_id" what type should I use to decode, is it correct?:

NSInteger *user_id = [dict objectForKey:@"user_id"];

If not, what's the right way to hold the integer json type?


Solution

  • TouchJSON will decode a number to NSNumber not NSInteger

    NSNumber *user_id = [dict objectForKey:@"user_id"];