I'm trying to use transformable with my entity class. Is that possible? if so how can i do that?
It's my core data properties code
import Foundation
import CoreData
extension PersonEntity {
@nonobjc public class func fetchRequest() -> NSFetchRequest<PersonEntity> {
return NSFetchRequest<PersonEntity>(entityName: "PersonEntity")
}
@NSManaged public var gender: String?
@NSManaged public var id: UUID?
@NSManaged public var name: String?
@NSManaged public var volunteered: Bool
@NSManaged public var schedules: NSSet?
}
// MARK: Generated accessors for schedules
extension PersonEntity {
@objc(addSchedulesObject:)
@NSManaged public func addToSchedules(_ value: ScheduleEntity)
@objc(removeSchedulesObject:)
@NSManaged public func removeFromSchedules(_ value: ScheduleEntity)
@objc(addSchedules:)
@NSManaged public func addToSchedules(_ values: NSSet)
@objc(removeSchedules:)
@NSManaged public func removeFromSchedules(_ values: NSSet)
}
extension PersonEntity : Identifiable {
}
and it's my core data class
import CoreData
@objc(PersonEntity)
public class PersonEntity: NSManagedObject, NSSecureCoding {
public static var supportsSecureCoding: Bool = true
enum Key: String {
case id = "id"
case name = "name"
case gender = "gender"
case volunteered = "volunteered"
}
init(id: UUID, name: String, gender: String, volunteered: Bool) {
self.id = id
self.name = name
self.gender = gender
self.volunteered = volunteered
// I'm getting Error here
// Must call a designated initializer of the superclass 'NSManagedObject'
super.init(entity: , insertInto: )
}
public func encode(with coder: NSCoder) {
coder.encode(id, forKey: Key.id.rawValue)
coder.encode(name, forKey: Key.name.rawValue)
coder.encode(gender, forKey: Key.gender.rawValue)
coder.encode(volunteered, forKey: Key.volunteered.rawValue)
}
required convenience public init?(coder: NSCoder) {
let decodedId = coder.decodeObject(forKey: Key.id.rawValue)
let decodedName = coder.decodeObject(forKey: Key.name.rawValue)
let decodedGender = coder.decodeObject(forKey: Key.gender.rawValue)
let decodedVolunteered = coder.decodeObject(forKey: Key.volunteered.rawValue)
self.init(id: decodedId as! UUID, name: decodedName as! String, gender: decodedGender as! String, volunteered: (decodedVolunteered != nil))
}
}
I'm really new here... sorry