核心日期更新

时间:2016-01-10 16:55:00

标签: swift core-data

我正在更新核心日期。我知道我需要取,但我不知道如何。在我的代码中,新记录来了,但没有更新。

代码:

@IBAction func saveBtm(sender: AnyObject) {

    do {
        let fetchRequest = NSFetchRequest()
        let entityDescription = NSEntityDescription.entityForName("Event", inManagedObjectContext: self.context)
        fetchRequest.entity = entityDescription
        let result = try self.context.executeFetchRequest(fetchRequest)
        fetchRequest.predicate = NSPredicate(format: "name == %@", nameDataPassed)
        if (result.count > 0) {
            let person = result[0] as! NSManagedObject 
            person.setValue(nameText.text, forKey: "name")
            person.setValue(surnameText.text, forKey: "surname")

0 个答案:

没有答案