1

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

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.

Remedy: Implement the custom class, or specify that the entity is represented by NSManagedObject.

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
)
Community
  • 1
  • 1
Chris
  • 335
  • 3
  • 10

1 Answers1

3

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: enter image description here

Ian
  • 12,538
  • 5
  • 43
  • 62
  • There is not enough information in the question but this looks like a different problem to me. Failing to prepend the module name to the Core Data class would cause a *"CoreData: warning: Unable to load class named ... Class not found, using default NSManagedObject instead."*, as in http://stackoverflow.com/questions/25076276/unabled-to-find-specific-subclass-of-nsmanagedobject. – Martin R Dec 21 '14 at 19:50
  • That's what I thought, but upon implementing this in the GitHub project, it fixed the error. Perhaps there is another underlying issue though. – Ian Dec 21 '14 at 19:54
  • Yes this solved the issue. In looking back in my old project, my Entity names are not prepended yet still continue to function. – Chris Dec 21 '14 at 20:54
  • Setting the model name in the core data modeler also resolved this issue for me. This sort of stuff is infuriating. – Andrew Theken Aug 10 '15 at 00:27