0

I've got an issue that just completely bewilders me. I've created a NSManagedObject subclass via the 'Editor' Menu in Xcode whilst in my .xcdatamodeld file. I've inserted a line in my program that fetches an object and sets it as the correct type, which is called Assignment. When the program loads up, it crashes on the line where I assign the object. The class is as follows:

import Foundation
import CoreData

class Assignment: NSManagedObject {

    @NSManaged var completedDate: NSDate
    @NSManaged var dueDate: NSDate
    @NSManaged var name: String
    @NSManaged var notes: String
    @NSManaged var teacher: String
    @NSManaged var type: String

}

Here is the line that the program crashes on:

let assignment: Assignment = fetchedResultsController.objectAtIndexPath(indexPath) as! Assignment

I can't say I've tried anything to fix this, as the error isn't all that much help:

2015-05-02 23:48:22.435 myHomework[14188:744047] CoreData: warning: Unable to load class named 'PRODUCT_MODULE_NAME.Assignment' for entity 'Assignment'.  Class not found, using default NSManagedObject instead.
Could not cast value of type 'NSManagedObject_Assignment_' (0x7feec15263b0) to 'myHomework.Assignment' (0x10fb58370).
Jeffrey
  • 1,231
  • 2
  • 15
  • 30
  • Creating managed object subclasses in Swift is (still) broken. You have to replace PRODUCT_MODULE_NAME manually by your module (app) name or apply any other solution of the referenced thread (such as marking the class with `@objc(Assignment)`). – Martin R May 03 '15 at 07:54
  • @MartinR Apple needs to step up their game. Once again, thanks for the help. ;) – Jeffrey May 03 '15 at 23:19

0 Answers0