我看到一个似乎是 iOS 5 独有的问题,尝试对字典进行编码会导致崩溃,因为在此过程中数组填充了一个 nil 对象。
这让我感到困惑,因为我认为为了发生以下情况,字典需要包含nil
,我希望在填充字典时而不是在编码时崩溃。
知道是什么原因造成的吗?
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
Last Exception Backtrace:
0 CoreFoundation 0x3277088f ___exceptionPreprocess + 163
1 libobjc.A.dylib 0x347c6259 _objc_exception_throw + 33
2 CoreFoundation 0x326c29e9 -[__NSPlaceholderArray initWithObjects:count:] + 129
3 Foundation 0x38071be7 -[NSDictionary(NSDictionary) encodeWithCoder:] + 819
4 Foundation 0x38047aa1 __encodeObject + 961
5 Tumblr 0x00105bab -[MyModelObject encodeWithCoder:] (MyModelObject.m:474)
6 Foundation 0x38047aa1 __encodeObject + 961
7 Foundation 0x380473c9 +[NSKeyedArchiver archivedDataWithRootObject:] + 161
8 CoreData 0x31e6cca7 -[NSSQLiteConnection execute] + 2219
9 CoreData 0x31f3455f -[NSSQLiteConnection updateRow:] + 551
10 CoreData 0x31f1120d -[NSSQLConnection performAdapterOperation:] + 85
11 CoreData 0x31f11183 -[NSSQLConnection performAdapterOperations:] + 115
12 CoreData 0x31f1c38b -[NSSQLCore _performChangesWithAdapterOps:] + 207
13 CoreData 0x31f1bfcb -[NSSQLCore performChanges] + 623
14 CoreData 0x31f1afc5 -[NSSQLCore saveChanges:] + 309
15 CoreData 0x31e7325f -[NSSQLCore executeRequest:withContext:error:] + 947
16 CoreData 0x31e72337 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1131
17 CoreData 0x31eda287 -[NSManagedObjectContext save:] + 523