简体   繁体   English

在Core Data iPhone应用程序中保存视图层次结构中的位置

[英]Saving position in view hierarchy in Core Data iPhone app

how would you go about saving a state in a tableview-drilldown, when using core data? 使用核心数据时,如何将状态保存在tableview-drilldown中? So next time you start the app, the drill down level you where at when you exit the app will be loaded in. 因此,下次您启动该应用程序时,将加载您退出该应用程序时所在位置的向下钻取级别。

I looked at apples drilldownsave sample code, but couldn't figure our how to change to code to work with core data. 我查看了applesrilldownsave示例代码,但无法弄清楚我们如何更改代码以使用核心数据。

Any help would be very appreciated. 任何帮助将不胜感激。 thanks in advance 提前致谢

Generally you shouldn't do that. 通常,您不应该这样做。 Usually (though not always) the model represents some concrete data, where as the position in the drill down is a transient property of a particular user using that data. 通常(尽管并非总是),该模型表示一些具体数据,其中,向下钻取中的位置是使用该数据的特定用户的临时属性。 Most of the time you are better off storing something like that as NSUserDefault, probably as an array of objectIDs for all the NSManagedObjects that should be instantiated and pushed onto the drill down on relaunch. 在大多数情况下,最好将诸如NSUserDefault之类的东西存储起来,可能作为所有NSManagedObjects的对象ID的数组,应实例化并推入向下钻取以重新启动。

Sometimes it makes sense to somehow encode that in the model, but in my experience that is not the common case. 有时以某种方式在模型中对它进行编码是有意义的,但是根据我的经验,这不是常见的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM