1

I'm using CoreData for my app and it would not run. I have an entity called "Task" and that entity has a class called Task.swift

This is the error message I'm getting;

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) 

Class:

import Foundation
import CoreData

class Task: NSManagedObject {

    @NSManaged var tDesc: String
    @NSManaged var tImage: NSData
    @NSManaged var tName: String

}

I have looked at other questions on this topic and they did not help much. I don't know what else to do. Can someone help please!

Thank You

enter image description here

enter image description here

Warnings

Wain
  • 117,132
  • 14
  • 131
  • 151
Zin Yackvaa
  • 475
  • 1
  • 3
  • 14
  • It looks like it should work. Try doing a Project->Clean and delete the ~/Library/Developer/Xcode/DerivedData/ToDoList-etc... folder. Then rebuild your project. — Sometimes that will solve mysterious problems. – ElmerCat Dec 08 '15 at 00:12
  • where do I find this folder – Zin Yackvaa Dec 08 '15 at 00:22
  • Using the Finder, press Command-Shift-G and enter: `~/Library/Developer/Xcode/DerivedData` — you'll see a folder for each project. Trash the one that begins with your project name. – ElmerCat Dec 08 '15 at 00:37
  • What do you get from typing `po NSClassFromString(@"Task")` into the debugging prompt after pausing execution? – Tommy Dec 08 '15 at 01:11
  • It's hard to tell. But I do notice that Xcode is showing 3 compiler warnings. Are those in any way related? – Tom Harrington Dec 08 '15 at 01:28
  • @Tommy this is what I'm getting. :1:25: error: invalid character in source file NSClassFromString(@"Task") ^ – Zin Yackvaa Dec 08 '15 at 02:31
  • @TomHarrington I don't think so. Look at the question I added the warnings – Zin Yackvaa Dec 08 '15 at 02:35
  • Can I add my whole project file here? – Zin Yackvaa Dec 08 '15 at 03:09
  • 1
    You have (at least) two completely unrelated problems here: #1: "CoreData: warning: Unable to load class named 'Task'": Have a look at http://stackoverflow.com/questions/25076276/unable-to-find-specific-subclass-of-nsmanagedobject. Did you set the module for the entity to "Current Product Module"? - #2 "*** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]": That is a probably caused by a missing reuse identifier in a prototype cell. – Martin R Dec 08 '15 at 06:07
  • @MartinR Yes I have added "Current Product Module" but it gives the same error. – Zin Yackvaa Dec 08 '15 at 06:16
  • I just did the project agian for the 3rd time and same error. – Zin Yackvaa Dec 08 '15 at 07:09
  • Thanks guys I fixed. – Zin Yackvaa Dec 08 '15 at 20:55

2 Answers2

3

The issue is with swift and package management. In the data model editor make sure the module is set correctly. If it is set to "none" then that is the source of your issue. Change it to be the current project.

Marcus S. Zarra
  • 46,143
  • 9
  • 99
  • 181
2

This may be a simulator error (Sometimes if you change the name of the core data file, or if you move your code around, the simulator data gets confused). Try going to the simulator and doing Simulator->Reset Content and Settings This will restart the simulator wiped clean.

fiacobelli
  • 1,912
  • 4
  • 22
  • 30