iOS 5:NSDictionary encodeWithCoder将nil插入数组

时间:2013-05-20 19:43:04

标签: ios nsarray nsdictionary nscoding

我看到一个似乎是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

0 个答案:

没有答案