ios - 核心数据错误 SIGABRT : keypath AttributeName not found in entity <NSSQLEntity EntityName id=2>

标签 ios swift sqlite core-data nsexception

我在我的 iOS 应用程序中使用核心数据。我有两个实体“Commit”,其属性为“commitID”、“completionStatus”、“contents”和“repeatStatus”,以及一个实体“ToDoList”,其属性为“dateID”。两者通过一种关系连接,该关系将许多提交与一个 ToDoList 相关联。

我每次都会收到以下错误。我尝试删除并重新安装该应用程序,但无济于事。我知道这个错误是在我的 application(application: 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)

最佳答案

来自错误消息:

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

它似乎正在尝试访问 ToDoList 实体上名为 commitID 的属性。这表明您的 fetch 或 fetched results Controller 配置不正确。

关于ios - 核心数据错误 SIGABRT : keypath AttributeName not found in entity <NSSQLEntity EntityName id=2>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37086657/

相关文章:

swift - 保存图片中的图片应用程序

swift - 给 View 一个≥高度约束给我 'Need Constraints for: Y position or height'(Swift)

java - 如何记录更改?

ios - 使用 UIWebView 进行基本身份验证

iOS 10 核心数据异常代码错误 : (6922)

ios - 路径中的线呈 180 度时出现意外的 LineJoinStyle 行为

java - 空 SQLite 数据字段是否占用额外内存?

iphone - MKMapView 的 visibleMapRect 属性没有正确设置 map 区域?

ios - UITableView + UICollectionView + UITableView 大小问题

ios - ipad 上的 SQLite3 问题。不断收到 'constraint failed' 错误