无法创建对象 - 简单核心数据应用程序 [英] Failed to Create Object - Simple Core Data App
问题描述
我刚刚试图创建一个简单的核心数据应用程序,但有一个错误。我使用Xcode 6.1和swift。我以前做过这个swift,没有任何问题,所以我很困惑,因为我错过了或忘记了。我在GitHub上的项目这里
I just tried to create a simple core data app but have an error. I am using Xcode 6.1 and swift. I've done this before in swift and didn't have any issues so I'm baffled as to what I've missed or forgotten. I have the project on GitHub here
错误代码在底部。在此处查看Apple的文档, Apple状态:
The error code is at bottom. In looking at Apple's Documentation here, Apple states:
原因:在您的托管对象模型中,您可能已为实体指定了自定义类,类。
Cause: In your managed object model, you may have specified a custom class for the entity, but you have not implemented the class.
补救措施:实现自定义类,或指定实体由NSManagedObject表示。
Remedy: Implement the custom class, or specify that the entity is represented by NSManagedObject.
我已经将Model的子类添加到项目中。
I have added the sub-class from the Model to the project.
任何人都有这个问题,可以指向正确的方向?
Anybody have this issue and can point me in the right direction?
2014-12-21 14:20:25.983 CoreDataNoStoryBoard[72437:7539866] Failed to create new object
2014-12-21 14:20:25.984 CoreDataNoStoryBoard[72437:7539866] (
0 CoreFoundation 0x00007fff9270c64c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8bb356de objc_exception_throw + 43
2 CoreFoundation 0x00007fff9270c42a +[NSException raise:format:arguments:] + 106
3 AppKit 0x00007fff98329507 _NSSendCommitEditingSelector + 267
4 AppKit 0x00007fff97fcd2bf -[NSController _controllerEditor:didCommit:contextInfo:] + 185
5 CoreFoundation 0x00007fff925e533c __invoking___ + 140
6 CoreFoundation 0x00007fff925e5192 -[NSInvocation invoke] + 290
7 CoreFoundation 0x00007fff92683e56 -[NSInvocation invokeWithTarget:] + 54
8 Foundation 0x00007fff9399eabb __NSFireDelayedPerform + 364
9 CoreFoundation 0x00007fff9265fb44 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
10 CoreFoundation 0x00007fff9265f7d3 __CFRunLoopDoTimer + 1059
11 CoreFoundation 0x00007fff926d2d9d __CFRunLoopDoTimers + 301
12 CoreFoundation 0x00007fff9261c268 __CFRunLoopRun + 2024
13 CoreFoundation 0x00007fff9261b838 CFRunLoopRunSpecific + 296
14 HIToolbox 0x00007fff8cc3643f RunCurrentEventLoopInMode + 235
15 HIToolbox 0x00007fff8cc360be ReceiveNextEventCommon + 179
16 HIToolbox 0x00007fff8cc35ffb _BlockUntilNextEventMatchingListInModeWithFilter + 71
17 AppKit 0x00007fff97bd86d1 _DPSNextEvent + 964
18 AppKit 0x00007fff97bd7e80 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194
19 AppKit 0x00007fff97bcbe23 -[NSApplication run] + 594
20 AppKit 0x00007fff97bb72d4 NSApplicationMain + 1832
21 CoreDataNoStoryBoard 0x00000001000059b2 top_level_code + 34
22 CoreDataNoStoryBoard 0x00000001000059ea main + 42
23 libdyld.dylib 0x00007fff97a805c9 start + 1
24 ??? 0x0000000000000003 0x0 + 3
)
推荐答案
NSManagedObject子类文档Swift类是命名空间 - 它们的范围限定到它们编译的模块(通常是项目)。要使用NSManagedObject类的Swift子类与您的Core Data模型,在模型实体检查器的Class字段中添加类名前缀
According to the NSManagedObject Subclass Documentation "Swift classes are namespaced—they’re scoped to the module (typically, the project) they are compiled in. To use a Swift subclass of the NSManagedObject class with your Core Data model, prefix the class name in the Class field in the model entity inspector with the name of your module."
将您的应用程序名称添加到实体的类中,如下所示:
Add your app name to the class of your entity like so:
这篇关于无法创建对象 - 简单核心数据应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!