iOS - 如何刷新/更新Core Data瞬态属性? [英] iOS - How to refresh/update Core Data transient property?

查看:169
本文介绍了iOS - 如何刷新/更新Core Data瞬态属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用核心数据,NSFetchedResultsController UITableView,具有瞬态NSDate属性。我有这个作为一个临时属性的主要原因是我的UITableView条目放入基于NSDate的部分,但可以在部分之间移动,当日期改变。



到目前为止,它似乎工作很好,但它只更新/刷新(我真的很新,所以我不知道如果我使用正确的术语,对不起!)当我关闭应用程序并杀死它从多任务,或重新运行它通过Xcode。如果我不这样做,项目不改变,不放入他们正确的部分。有没有办法手动让它刷新,所以用户不需要这样做才能让它运行正确?



谢谢!

$当发送 refreshObject:mergeChanges: c>到你的对象。



Mundi提供的应用键值观察机制的解决方案也可能工作,如果是这样,肯定比显式刷新更方便。


I'm using a core data, NSFetchedResultsController UITableView, with a transient NSDate attribute. The main reason I have this as a transient property is so my UITableView entries get put into sections based on NSDate, but can move between the sections when the date changes.

So far it seems to work great, but it only updates/refreshes (I'm really new to this, so I don't know if I'm using the correct terminology, sorry!) when I either close the app and kill it from multitasking, or re-run it through Xcode. If I don't do that, the items don't change and aren't put into their correct sections. Is there a way to manually get it to refresh so the user doesn't need to do that to get it to run right?

Thank you!

解决方案

Transient properties are refreshed when you send a refreshObject:mergeChanges: to your object.

The solution provided by Mundi to apply key value observing mechanism might work too and if it does, it is definitely much more convenient than refreshing explicitly.

这篇关于iOS - 如何刷新/更新Core Data瞬态属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆