앱을 홈버튼을 눌러 끄고 다시 실행 시키면 다시 작업중이던 작업이 그대로 뜨게 해주는 설정입니다.
아래 처럼 ID를 설정해주고
그리고 두 메서드를 AppDeligate에 넣어 주어야 합니다.
func application(application: UIApplication,
shouldRestoreApplicationState coder: NSCoder) -> Bool {
return true
}
func application(application: UIApplication,
shouldSaveApplicationState coder: NSCoder) -> Bool {
return true
}
override func encodeRestorableStateWithCoder(coder: NSCoder) {
coder.encodeObject(myTextView.text, forKey:"UnsavedText")
super.encodeRestorableStateWithCoder(coder)
}
override func decodeRestorableStateWithCoder(coder: NSCoder) {
if let decodedObj = coder.decodeObjectForKey("UnsavedText") {
myTextView.text = decodedObj as! String
}
super.decodeRestorableStateWithCoder(coder)
}