Jonas Jonas - 6 months ago 38
Swift Question

CoreData Error SIGABRT: keypath AttributeName not found in entity <NSSQLEntity EntityName id=2>

I use core data in my iOS App. I have two entities, "Commit", with attributes "commitID", "completionStatus", "contents" and "repeatStatus" as well as an entity "ToDoList" with the attribute "dateID". The two are connected via a relationship that relates many Commits to one ToDoList.

I get the following error every time. I have tried deleting and reinstalling the app, to no avail. I know this error is thrown after my application(application: didFinishLaunchingWithOptions:) method:

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)

Answer

From the error message:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath commitID not found in entity [NSSQLEntity ToDoList id=2]'

it seems to be trying to access an attribute named commitID on the ToDoList entity. That suggests you have a fetch or fetched results controller that is configured incorrectly.