我正在为我的应用程序使用CoreData,但它无法运行。我有一个名为" Task"并且该实体有一个名为Task.swift的类
这是我收到的错误消息;
2015-12-07 17:13:24.669 ToDoList[8002:64192] CoreData: warning: Unable to load class named 'Task' for entity 'Task'. Class not found, using default NSManagedObject instead.
2015-12-07 17:13:24.677 ToDoList[8002:64192] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-3347.44.2/UITableView.m:6245
2015-12-07 17:13:24.679 ToDoList[8002:64192] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier reuseIdentifier - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f7ebc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000111356bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010f7ebaca +[NSException raise:format:arguments:] + 106
3 Foundation 0x000000010fc8898f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x000000011017e264 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 153
5 ToDoList 0x000000010f1efd83 _TFC8ToDoList27TaskListTableViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 147
6 ToDoList 0x000000010f1f029f _TToFC8ToDoList27TaskListTableViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 79
7 UIKit 0x000000011018b9e8 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508
8 UIKit 0x000000011016a208 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2853
9 UIKit 0x0000000110180869 -[UITableView layoutSubviews] + 210
10 UIKit 0x000000011010a9eb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
11 QuartzCore 0x0000000113ed8ed2 -[CALayer layoutSublayers] + 146
12 QuartzCore 0x0000000113ecd6e6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
13 QuartzCore 0x0000000113ecd556 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
14 QuartzCore 0x0000000113e3986e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
15 QuartzCore 0x0000000113e3aa22 _ZN2CA11Transaction6commitEv + 462
16 UIKit 0x00000001100889ed -[UIApplication _reportMainSceneUpdateFinished:] + 44
17 UIKit 0x00000001100896b1 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2648
18 UIKit 0x0000000110088095 -[UIApplication workspaceDidEndTransaction:] + 179
19 FrontBoardServices 0x0000000112e535e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
20 CoreFoundation 0x000000010f71f41c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
21 CoreFoundation 0x000000010f715165 __CFRunLoopDoBlocks + 341
22 CoreFoundation 0x000000010f714f25 __CFRunLoopRun + 2389
23 CoreFoundation 0x000000010f714366 CFRunLoopRunSpecific + 470
24 UIKit 0x0000000110087b02 -[UIApplication _run] + 413
25 UIKit 0x000000011008a8c0 UIApplicationMain + 1282
26 ToDoList 0x000000010f1ecb47 main + 135
27 libdyld.dylib 0x0000000111a8c145 start + 1
28 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
类别:
import Foundation
import CoreData
class Task: NSManagedObject {
@NSManaged var tDesc: String
@NSManaged var tImage: NSData
@NSManaged var tName: String
}
我已经看过关于这个主题的其他问题,但他们并没有多大帮助。我不知道还能做什么。请有人帮忙!
谢谢
答案 0 :(得分:3)
问题在于快速和包管理。在数据模型编辑器中,确保模块设置正确。如果设置为“none”,那么这就是您的问题的根源。将其更改为当前项目。
答案 1 :(得分:2)
这可能是模拟器错误(有时如果您更改核心数据文件的名称,或者如果您移动代码,则模拟器数据会混淆)。 尝试进入模拟器并执行模拟器 - >重置内容和设置 这将重新启动模拟器擦干净。