So I am using core data and I have to make my class Decodable to use the decoder for my get request. The errors I get are 'self' used in property access before 'super.init' call in my CoreDataClass each of my decode values has the error.
CoreDataProperties
CoreDataClass
CoreDataProperties
Code Block extension CurrentPlayers { @nonobjc public class func fetchRequest() -> NSFetchRequest<CurrentPlayers> { return NSFetchRequest<CurrentPlayers>(entityName: "CurrentPlayers") } @NSManaged public var photoUrl: String? @NSManaged public var firstName: String? @NSManaged public var lastName: String? @NSManaged public var position: String? @NSManaged public var team: String? @NSManaged public var yahooName: String? @NSManaged public var status: String? @NSManaged public var jerseyNumber: Int64 } extension CurrentPlayers : Identifiable { }
CoreDataClass
Code Block @objc(CurrentPlayers) public class CurrentPlayers: NSManagedObject, Decodable { enum CodingKeys: String, CodingKey { case photoUrl = "PhotoUrl" case firstName = "FirstName" case lastName = "LastName" case position = "Position" case team = "Team" case yahooName = "YahooName" case status = "Status" case jerseyNumber = "JerseyNumber" } required public init(from decoder: Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) photoUrl = try values.decode(String.self, forKey: CodingKeys.photoUrl) firstName = try values.decode(String.self, forKey: CodingKeys.firstName) lastName = try values.decode(String.self, forKey: CodingKeys.lastName) position = try values.decode(String.self, forKey: CodingKeys.position) team = try values.decode(String.self, forKey: CodingKeys.team) yahooName = try values.decode(String.self, forKey: CodingKeys.yahooName) status = try values.decode(String.self, forKey: CodingKeys.status) jerseyNumber = Int64(try values.decode(Int.self, forKey: CodingKeys.jerseyNumber)) } }
Seems you do not think PlayersVC or cPlayerArr is related...
OK, I can guess, just that makes me spend more time.
OK, I can guess, just that makes me spend more time.
Code Block let decoder = JSONDecoder() let appDelegate = UIApplication.shared.delegate as! AppDelegate //<- Intentionally using forced casting. decoder.userInfo[.managedObjectContext] = appDelegate.persistentContainer.viewContext