![](/img/trans.png)
[英]Error: Terminating app due to uncaught exception 'NSUnknownKeyException'
[英]How Do I Fix: Terminating app due to uncaught exception 'NSUnknownKeyException'
我讀過其他人也有類似的未捕獲異常,但是大多數似乎是由於缺少出口連接引起的。 我不認為我的與IBOutlets
有關,因為VC
在大多數情況下都能正常運行,而我的其他VCs
也是如此。
我認為這與Core Data
。 這是錯誤,我認為該錯誤發生在表的cellForRowAtIndexPath
:
2016-01-05 15:18:14.947 Do List[1476:81278] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSManagedObject 0x7fbb89e7cc50> valueForUndefinedKey:]: the entity TomTask is not key value coding-compliant for the key "completedDate".'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102b5ee65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000104cfddeb objc_exception_throw + 48
2 CoreFoundation 0x0000000102b5eaa9 -[NSException raise] + 9
3 CoreData 0x0000000102757ec1 -[NSManagedObject valueForUndefinedKey:] + 289
4 Do List 0x000000010235b9d6 _TFC7Do_List24AllocationViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 2630
5 Do List 0x000000010235c24f _TToFC7Do_List24AllocationViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 79
6 UIKit 0x0000000103933e43 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 766
7 UIKit 0x0000000103933f7b -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
8 UIKit 0x0000000103908a39 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2996
9 UIKit 0x000000010393d01c -[UITableView _performWithCachedTraitCollection:] + 92
10 UIKit 0x0000000103923edc -[UITableView layoutSubviews] + 224
11 UIKit 0x00000001038914a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
12 QuartzCore 0x000000010369659a -[CALayer layoutSublayers] + 146
13 QuartzCore 0x000000010368ae70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
14 QuartzCore 0x000000010368acee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
15 QuartzCore 0x000000010367f475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
16 QuartzCore 0x00000001036acc0a _ZN2CA11Transaction6commitEv + 486
17 UIKit 0x00000001037d4f7c _UIApplicationHandleEventQueue + 7329
18 CoreFoundation 0x0000000102a8aa31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
19 CoreFoundation 0x0000000102a8095c __CFRunLoopDoSources0 + 556
20 CoreFoundation 0x0000000102a7fe13 __CFRunLoopRun + 867
21 CoreFoundation 0x0000000102a7f828 CFRunLoopRunSpecific + 488
22 GraphicsServices 0x0000000106bb7ad2 GSEventRunModal + 161
23 UIKit 0x00000001037da610 UIApplicationMain + 171
24 Do List 0x0000000102368fad main + 109
25 libdyld.dylib 0x000000010a52392d start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
一些注意事項
有一組特定的VCs
, 如果以特定的順序運行 , 則會導致此錯誤。
當我從A -> B -> C
,然后嘗試展開到A
時,會發生錯誤。
如果您查看上面的異常堆棧,則該錯誤發生在allocViewController
的cellForRowAtIndexPath
中。 那個VC
是B
,所以它不應該被加載,只是被解開。
它引用了“ CompletedDate
”,這是我昨天添加的新內容,可以使整個過程順利進行。 CompletedDate
是現有的CoreData
屬性,我剛剛開始在view controller
C
顯示它。
如果您查看錯誤的第一行,則好像您有一個名為TomTask的類,您正在嘗試使用該類中的“ completedDate”,但TomTask中沒有“ completedDate”。
您正在嘗試在該視圖控制器的tableView:cellForRowAtIndexPath:
方法中(從調用堆棧中的第4條開始)執行此操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.