I created the Diary table. Also created two files Diary.swift and Diary + CoreDataProperties.swift
In the first, just the class notation:
import Foundation import CoreData @objc(Diary) class Diary: NSManagedObject { // Insert code here to add functionality to your managed object subclass } In the second, the field designation: import Foundation import CoreData
extension Diary { @NSManaged var activity: NSNumber? @NSManaged var activityDescription: String? @NSManaged var alcohol: NSNumber? @NSManaged var alcoholDescription: String? @NSManaged var basalInsulin: NSNumber? @NSManaged var bolusInsulin: NSNumber? @NSManaged var carbs: NSNumber? @NSManaged var carbsDescription: String? @NSManaged var diaryID: NSNumber? @NSManaged var extID: NSNumber? @NSManaged var glucoseLevel: NSNumber? @NSManaged var note: String? @NSManaged var remindUtcDateTime: NSDate? @NSManaged var sectionIdentifier: String? @NSManaged var signs: NSNumber? @NSManaged var synced: NSNumber? @NSManaged var time: String? @NSManaged var utcDateTime: String? @NSManaged var valid: NSNumber? } But when I try to create an object of this class, he writes me an error:
CoreData: warning: Unable to load class named 'Diary' for entity 'Diary'. Class not found, using default NSManagedObject instead.
On English sites I read that before the designation of the class Diary should be put
@objc(Diary) CoreData: error: Failed to call the initializer on NSManagedObject class 'Diary'
And if I try to define, for example, activity, then he writes
[Diary setActivity:]: unrecognized selector sent to instance 0x7fed187ccb60 2015-11-03 16: 43: 31.143 journal [29592: 767498] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [Diary setActivity:] : unrecognized selector sent to instance 0x7fed187ccb60 '
I also read what I need in the .xcdatamodeld file to specify not just the Diary class for the table, but the entire value (journal.Diary), but XCode automatically removes the dot from me and that does not help.