Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

}
like image 725
tHatpart Avatar asked Dec 22 '18 00:12

tHatpart


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 {
like image 131
RateRebriduo Avatar answered Oct 08 '22 06:10

RateRebriduo