1

I am fairly new to iOS development and I am trying to understand the State Restoration API. Without implementing the APIs in my application, when the application is exited and resumed it does restore the state of the application to the way it was before the user exited. If this is not State Restoration, then what mechanism is this? And how is it different than State Restoration? Why should I implement state restoration when the default mechanism seems to do what I need.

I'm sure that I'm just not understanding something, but I don't know what it is.

4

1 回答 1

1

如果您打开多任务托盘并强制退出您的应用程序,如果您没有实施任何恢复状态的方法,则应用程序将启动并像正常一样通过其 UIWindow 层次结构运行applicationDidFinishLaunching。状态恢复只是提供了一种简单的方法来归档符合 NSCoding 的对象,所以如果你决定让你的视图层次结构兼容,例如,你可以传入你的导航堆栈。然后,当启动时调用正确的方法时,如果应用程序没有退出暂停状态而是冷启动,它将使用这些归档对象重新填充层次结构。

但是,它不仅实现了几种方法,还没有免费为您处理状态恢复。我只是相信它可以处理归档发生的位置和文件名。您可以决定要归档的内容以及取消归档对象时如何处理这些对象。

于 2013-07-08T18:55:38.467 回答