我正试图以这种方式制作一个json字符串:
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:JSONDictionary options:NSJSONWritingPrettyPrinted error:&error];
NSString* json = nil;
if (! jsonData) {
NSLog(@"Got an error: %@", error);
} else {
json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
其中JSONDictionary初始化为:
NSDictionary *JSONDictionary = [NSDictionary dictionaryWithObjectsAndKeys: dateString, @"start", [self.currentlyConnectedPeripheral UUID], @"device_id", [self.currentlyConnectedPeripheral name], @"device_name", rrs, @"rates", @"123", @"id", nil];
但我的申请引发了一个例外:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (__NSCFType)' ***
我的问题是什么,如何让它发挥作用?