get touchJson data for int type

57 Views Asked by At

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?

1

There are 1 best solutions below

1
Michael Boselowitz On BEST ANSWER

TouchJSON will decode a number to NSNumber not NSInteger

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