How to get boolean value from JSON?
ios, iphone, objective-c
Solution
BOOL *retweeted;
this is wrong, booleans are scalars, not Objective-C objects, so they don't need to be declared as pointers. Use
BOOL retweeted;
instead.
Problem
Suppose this is a value in a JSON I want to assign to a BOOL variable: ``` "retweeted": false ``` Here is how I parse JSON data: ``` NSError *error; NSArray *timeline = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error]; ``` Now, I have a bool property defined as: ``` BOOL *retweeted; ``` Inside my class. When I do this while parsing the JSON: ``` tweet.retweeted = [[[timeline objectAtIndex:i] objectForKey:@"retweeted"] boolValue]; ``` I get this error: How to solve this problem?