This question is similar to: How do you store "int" values in an NSMutableArray* or NSMutableDictionary*? Chronic problems with JSON data that come in as integers.
How do you do this with Boolean values?
How do you store "bool" values in an NSMutableArray* or NSMutableDictionary*? Chronic problems with JSON data that come in as Boolean values.
You can store it as a number:
[mutableArray addObject[NSNumber numberWithBool:YES]];
EDIT And with the new syntax:
//BOOL
[mutableArray addObject:@YES];
//integer
[mutableArray addObject:@23];
You should simply wrap the bool in an NSNumber as follows:
NSNumber *wrappedBool = [NSNumber numberWithBool:YES];
For future reference, NSNumber has quite a few numberWith... methods for wrapping booleans, ints, floats, etc.
You can also use JSON-Framework which abstracts away all those difficulties.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With