CoreData错误SIGABRT:在实体未发现的keyPath的AttributeName

问题描述:

我用在我的iOS应用的核心数据。我有两个实体,“Commit”,属性为“commitID”,“completionStatus”,“contents”和“repeatStatus”,以及具有属性“dateID”的实体“ToDoList”。这两者通过一种关系将许多提交关联到一个ToDoList。CoreData错误SIGABRT:在实体未发现的keyPath的AttributeName <NSSQLEntity实体名称ID = 2>

我每次都收到以下错误。我尝试删除并重新安装应用程序,无济于事。我知道这个错误是我的应用程序(应用程序后抛出中:didFinishLaunchingWithOptions :)方法:

2016-05-07 10:54:14.131 CommitToday[1836:47383] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath commitID not found in entity <NSSQLEntity ToDoList id=2>' 
*** First throw call stack: 
(
0 CoreFoundation      0x00000001027d7d85 __exceptionPreprocess + 165 
1 libobjc.A.dylib      0x000000010457bdeb objc_exception_throw + 48 
2 CoreData       0x000000010242efff -[NSSQLGenerator newSQLStatementForRequest:ignoreInheritance:countOnly:nestingLevel:nestIsWhereScoped:] + 1583 
3 CoreData       0x00000001023217e3 -[NSSQLGenerator newSQLStatementForFetchRequest:ignoreInheritance:countOnly:nestingLevel:nestIsWhereScoped:] + 35 
4 CoreData       0x00000001024147b8 -[NSSQLAdapter _statementForFetchRequest:ignoreInheritance:countOnly:nestingLevel:] + 344 
5 CoreData       0x000000010232167c -[NSSQLAdapter _newSelectStatementWithFetchRequest:ignoreInheritance:] + 316 
6 CoreData       0x00000001023212f6 -[NSSQLCore newRowsForFetchPlan:] + 118 
7 CoreData       0x0000000102320bac -[NSSQLCore objectsForFetchRequest:inContext:] + 524 
8 CoreData       0x0000000102320549 -[NSSQLCore executeRequest:withContext:error:] + 377 
9 CoreData       0x0000000102405eaf __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 3311 
10 CoreData       0x000000010240f4dd gutsOfBlockToNSPersistentStoreCoordinatorPerform + 189 
11 CoreData       0x00000001024005ed _perform + 221 
12 CoreData       0x00000001023201b4 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 500 
13 CoreData       0x000000010231e973 -[NSManagedObjectContext executeFetchRequest:error:] + 579 
14 CoreData       0x000000010244d6c2 __43-[NSFetchedResultsController performFetch:]_block_invoke + 258 
15 CoreData       0x000000010240f4dd gutsOfBlockToNSPersistentStoreCoordinatorPerform + 189 
16 libdispatch.dylib     0x00000001050143eb _dispatch_client_callout + 8 
17 libdispatch.dylib     0x0000000104ff8ef5 _dispatch_barrier_sync_f_invoke + 393 
18 CoreData       0x00000001023ff076 -[NSPersistentStoreCoordinator performBlockAndWait:] + 198 
19 CoreData       0x0000000102366127 developerSubmittedBlockToNSManagedObjectContextPerform + 199 
20 CoreData       0x0000000102365fee -[NSManagedObjectContext performBlockAndWait:] + 222 
21 CoreData       0x000000010244d4bc -[NSFetchedResultsController performFetch:] + 524 
22 CommitToday       0x00000001022404e4 _TFC11CommitToday14ViewController11viewDidLoadfT_T_ + 164 
23 CommitToday       0x0000000102240d42 _TToFC11CommitToday14ViewController11viewDidLoadfT_T_ + 34 
24 UIKit        0x000000010319a984 -[UIViewController loadViewIfRequired] + 1198 
25 UIKit        0x00000001031defae -[UINavigationController _layoutViewController:] + 54 
26 UIKit        0x00000001031df882 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 462 
27 UIKit        0x00000001031df9f4 -[UINavigationController _startTransition:fromViewController:toViewController:] + 126 
28 UIKit        0x00000001031e0c4d -[UINavigationController _startDeferredTransitionIfNeeded:] + 890 
29 UIKit        0x00000001031e1d0b -[UINavigationController __viewWillLayoutSubviews] + 57 
30 UIKit        0x0000000103390503 -[UILayoutContainerView layoutSubviews] + 248 
31 UIKit        0x00000001030ba980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703 
32 QuartzCore       0x0000000107aafc00 -[CALayer layoutSublayers] + 146 
33 QuartzCore       0x0000000107aa408e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 
34 QuartzCore       0x0000000107aa3f0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 
35 QuartzCore       0x0000000107a983c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277 
36 QuartzCore       0x0000000107ac6086 _ZN2CA11Transaction6commitEv + 486 
37 QuartzCore       0x0000000107ac67f8 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92 
38 CoreFoundation      0x00000001026fcc37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 
39 CoreFoundation      0x00000001026fcba7 __CFRunLoopDoObservers + 391 
40 CoreFoundation      0x00000001026f211c CFRunLoopRunSpecific + 524 
41 UIKit        0x0000000102ffaf21 -[UIApplication _run] + 402 
42 UIKit        0x0000000102ffff09 UIApplicationMain + 171 
43 CommitToday       0x000000010223c302 main + 114 
44 libdyld.dylib      0x000000010504892d start + 1 
45 ???         0x0000000000000001 0x0 + 1 
) 
    libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 
+0

你有多个版本的核心数据模型吗? –

+0

我如何知道我的核心数据模型有多少个版本? – Jonas

+0

您将选择* .xcdatamodel文件,然后在右侧单击“显示文件检查器”,然后查看“模型版本” - >“当前版本”部分并选择一个 –

从错误消息:

终止应用程序由于未捕获的异常 'NSInvalidArgumentException',原因是:“的keyPath的commitid在实体没有找到[NSSQLEntity TodoList的ID = 2]”

它似乎是试图在ToDoList实体访问名为commitID的属性。这表明您有一个配置不正确的提取或提取结果控制器。