swift - 如何更新核心数据中的值?
问题描述
每次学习闪存卡时,我都会尝试更新闪存卡分数,但分数并没有保存。我究竟做错了什么?
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
解决方案
推荐阅读
- java - 如何将 url 图像加载到位图,将其转换为可绘制并使用 imageview 显示
- sql-server - 使用 OPENROWSET 通过 SQL Server 提供程序查询 Active Directory 时出错
- ios - Xamarin iOS 项目中的自动预配
- c++11 - 如何解决此错误“请求从'B'转换为非标量类型'D'”?(试图在基类的字段之间做“运算符+”)
- sass - 如何使用 sass mixin 附加一组类
- javascript - 如何使用asp C#从日期范围选择器中获取值
- xml - 如何在 XML 标记中转义 @ 符号
- scala - Scala,结合异构地图 - Hmap 与 monoid 操作
- python - 递归二分查找python
- mongodb - 检索动态子文档键