我想用MagicalRecord保存一些记录:
func saveCoreData(domain: String){
let moc = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let siteEntity = NSEntityDescription.entity(forEntityName: "SiteDB", in: moc)!
let siteDB = NSManagedObject(entity: siteEntity, insertInto: moc)
MagicalRecord.save({ (localContext: NSManagedObjectContext!) in
siteDB.setValue(domain, forKeyPath: "domain")
})
}
但是我在控制台中找到了它:
[NSManagedObjectContext(MagicalSaves)
MR_saveWithOptions:completion:](0x600001d0cb40) NO CHANGES IN **
UNNAMED ** CONTEXT - NOT SAVING
我应该如何保存它?
这是我的核心数据
extension SiteDB {
@nonobjc public class func fetchRequest() -> NSFetchRequest<SitesDB> {
return NSFetchRequest<SiteDB>(entityName: "SiteDB")
}
@NSManaged public var domain: String?
}