Property cannot be marked @NSManaged because its type cannot be represented in Objective-C

Viewed 8333

I am trying to save a custom class into core data but it is giving me this error on @NSManaged public var deck: [card]? in the generated NSManagedSubClass. Could anyone point me in the right direction?

extension Deck {

    @nonobjc public class func fetchRequest() -> NSFetchRequest<Deck> {
        return NSFetchRequest<Deck>(entityName: "Deck")
    }

    @NSManaged public var deck: [card]?
    @NSManaged public var name: String?

}
1 Answers
 @NSManaged public var deck: [card]?

The card of this line of code is a custom class, you cannot use it as a datatype in your NSManagedObject.

The solution is making Card a subclass of NSObject:

class Card: NSObject {
Related