MagicalRecord不保存任何内容

时间:2019-01-17 20:24:03

标签: swift core-data magicalrecord

我想用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?


}

And a screenshot of the model

0 个答案:

没有答案