<span style= "font-size: 14px;" >- ( BOOL )application:(UIApplication *)application shouldSaveApplicationState:( NSCoder
*)coder { return
YES ; } - ( BOOL )application:(UIApplication *)application shouldRestoreApplicationState:( NSCoder
*)coder { return
YES ; }</span> |
<span style= "font-size: 14px;" >- ( void )encodeRestorableStateWithCoder:( NSCoder
*)coder { [ super
encodeRestorableStateWithCoder:coder]; [coder encodeObject: self .doorPhoto forKey:@ "doorPhoto" ]; } - ( void )decodeRestorableStateWithCoder:( NSCoder
*)coder { [ super
decodeRestorableStateWithCoder:coder]; self .doorPhoto = [coder decodeObjectForKey:@ "doorPhoto" ]; }</span> |
当在程序中按下home键的时候,就会调用encodeRestorableStateWithCoder:来保存你想要保存的对象,再下一次打开程序的时候,就会调用decodeRestorableStateWithCoder:来恢复你之前保存好的对象。
原文:http://www.cnblogs.com/adamleung/p/3512893.html