1
我需要生成POST數據的JSON並獲取異常。NSJSONSerialization不解析NSManagedObject
這是帶有「記錄」鍵的字典,其中包含NSManagedObjects
的數組。
它似乎是拋出一個異常時,解析成json。
NSData *postData = [NSJSONSerialization dataWithJSONObject:[super requestData] options:0 error:&error];
它失敗,出現以下異常。任何想法爲什麼發生這種情況?
'NSInvalidArgumentException', reason: 'Invalid type in JSON write (FTRecord)'
*** First throw call stack:
(
0 CoreFoundation 0x01aae5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018318b6 objc_exception_throw + 44
2 CoreFoundation 0x01aae3bb +[NSException raise:format:] + 139
3 Foundation 0x015760f0 _writeJSONValue + 771
4 Foundation 0x0157a470 ___writeJSONArray_block_invoke + 129
5 CoreFoundation 0x01b2b05d __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 61
6 CoreFoundation 0x01b2af92 -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 258
7 CoreFoundation 0x01aa80a5 -[NSArray enumerateObjectsUsingBlock:] + 53
8 Foundation 0x0157a381 _writeJSONArray + 275
FTRecord:
@interface FTRecord : NSManagedObject
@property (nonatomic) BOOL isRealEntry;
@property (nonatomic) NSTimeInterval timestamp;
@property (nonatomic, retain) NSString * notes;
@property (nonatomic) double orderingValue;
@property (nonatomic) int16_t rating;
@property (nonatomic) NSTimeInterval recordDate;
@end