# StateRestorationDemo
#### Swift app to demonstrate state preservation and restoration APIs.
![](https://raw.githubusercontent.com/shagedorn/StateRestorationDemo/master/Presentation/app_screenshot.png)
Created for a presentation at CocoaHeads Dresden on 09 July 2014. The Deckset
presentation (rendered as PDF and the Markdown source) is included in the
repository. Feel free to open a GitHub Issue for questions regarding this project.
Last verified with Xcode 14.3 and iOS 16.2. The app is written in Swift 5.7.
⚠️ This app demonstrates view- and view-controller-based state restoration in
UIKit. As of iOS 13, Apple encourages to adopt user-activity-based state
restoration.
Please consult the [official documentation](https://developer.apple.com/documentation/uikit/uiviewcontroller/restoring_your_app_s_state)
for a comparison of the two approaches and official demo material.
## Tags
Tags outline the various steps to enable state restoration in iOS apps:
+ `NO_STATE_RESTORATION`: The app without state restoration
+ `STATE_RESTORATION_OPT_IN`: The app generally enables state restoration, but does not implement it yet
+ `RESTORATION_IDENTIFIERS`: The app sets restoration identifiers on view controllers, but the controllers are not restored successfully yet
+ `BASIC_STATE_RESTORATION`: Initially created view controllers are restored successfully
+ `RESTORATION_CLASS`: Non-initial view controllers are restored, too
+ `STATE_ENCODING`: View controllers restore their views' state
+ `SIZE_CLASSES`: The window's size classes are preserved
**Note:** Both to improve the project and to support the current version of
Swift, there have been major updates that are not reflected by the tagged
commits. The tags are still helpful to follow the various steps, but you
should use the latest commit on `main` for a working version.
## Limitations
By default, state restoration happens synchronously at launch on the main queue.
While you can [move work off the main queue](https://developer.apple.com/documentation/uikit/uiapplication/1623060-extendstaterestoration),
it will still kick in right after app launch and should finish as quickly as
possible, which means it cannot easily be adopted by apps that need to log in
or fetch a new session on every launch.
## Other Resources
[Apple Sample Code: State Restoration of Child View Controllers](https://developer.apple.com/library/content/samplecode/StateRestoreChildViews/)
没有合适的资源?快使用搜索试试~ 我知道了~
演示状态保存和恢复API的应用程序_Swift_下载.zip
共31个文件
xib:4个
swift:4个
json:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 139 浏览量
2023-04-28
13:39:11
上传
评论
收藏 6.95MB ZIP 举报
温馨提示
演示状态保存和恢复API的应用程序_Swift_下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
演示状态保存和恢复API的应用程序_Swift_下载.zip (31个子文件)
StateRestorationDemo-main
.swiftlint.yml 3KB
LICENSE.md 1KB
StateRestorationDemo
CityViewController.swift 3KB
Images.xcassets
Contents.json 63B
Dresden.imageset
Dresden@2x.jpg 1.48MB
Contents.json 160B
AppIcon.appiconset
Contents.json 177B
Cologne.imageset
Contents.json 160B
Cologne@2x.jpg 2.65MB
FirstViewController.swift 2KB
SecondViewController.swift 3KB
FirstViewController.xib 3KB
SecondViewController.xib 5KB
AppDelegate.swift 4KB
Launch Screen.xib 3KB
Info.plist 918B
CityViewController.xib 4KB
StateRestorationDemo.xcodeproj
project.pbxproj 15KB
xcuserdata
Hagi.xcuserdatad
xcdebugger
Breakpoints_v2.xcbkptlist 91B
xcschemes
StateRestorationDemo.xcscheme 4KB
xcschememanagement.plist 582B
project.xcworkspace
xcshareddata
IDEWorkspaceChecks.plist 238B
WorkspaceSettings.xcsettings 241B
contents.xcworkspacedata 165B
Presentation
data_example.png 66KB
log_example.png 117KB
Presentation.pdf 2.33MB
State Restoration.md 9KB
app_screenshot.png 434KB
.gitignore 211B
README.md 2KB
共 31 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功