如何更新核心数据中的值?

时间:2019-01-21 21:17:38

标签: swift core-data

每次尝试学习闪存卡时,我都试图更新其分数,但是分数没有保存。我在做什么错了?

do {

    fetchedCards = try context.fetch(Cards.fetchRequest())

    for cards in fetchedCards {
        if(termLabel.text == cards.term){
            cards.score = score
            ad.saveContext()
            continue
        }
    }

} catch {

}


let ad = UIApplication.shared.delegate as! AppDelegate
let context = ad.persistentContainer.viewContext

0 个答案:

没有答案