首页 > 解决方案 > 如何更新核心数据中的值?

问题描述

每次学习闪存卡时,我都会尝试更新闪存卡分数,但分数并没有保存。我究竟做错了什么?

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

标签: swiftcore-data

解决方案


推荐阅读