我需要生成 POST 数据的 JSON 并获得异常。
这是带有“记录”键的字典,其中包含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
FT记录:
@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