This feels like a super newb question, so apologizes in advance.
How does one specify booleans when using NSJSONSerialization?
My current code is below:
NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:
value, @"key",
NO, @"booleanKey",
nil];
NSData *jsondata = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsondata encoding:NSUTF8StringEncoding];
It just seems to be ignoring it and the NSLog output looks like:
{"key":"THE VALUE OF id value"}
The reason that it is getting ignored is because
NOis the same asnil, which terminates your dictionary list. You can only add objects into your dictionary, thus turn any primitive types into objects. E.g.:NOturns to[NSNumber numberWithBool:NO]or if you are using Xcode 4.4 you can just use@(NO).