Hey,
I'm trying to save state in my application. So far I can successfully save the 'backend' of what the user has changed but not committed to the database via NSCoding and storing the resulting NSData object as a User Default.
The problem I am having is in restoring the UIViewControllers. My setup consists of a main view controller (loaded when the application starts) and then it can display one of two modal view controllers:
...........................MyAppDelegate..............................
.........................MainViewController...........................
....ModalViewController1.....ModalViewController2....
I originally tried to make the MainViewController/ModalViewController1/2 NSCoding compliant, so when my app terminates it archives MainViewController, which will then go on to archive its modal view controller (and they archive the backed instance). I was then going to restore the MainViewController when my application restarts, presenting the correct modal view controller within its initWithCoder: method, but it didn't really go to plan. I got errors from encoding view controllers that contained UIImage's (I wasn't trying to encode the UIImage directly since it doesn't support NSCoding, but when I call [super encodeWithCoder:coder] the UIViewController seems to try and encode them).
Am I going about this the right way and just messing something up or is there a different, more correct approach?
Thanks for your time,
-Ross
I'm trying to save state in my application. So far I can successfully save the 'backend' of what the user has changed but not committed to the database via NSCoding and storing the resulting NSData object as a User Default.
The problem I am having is in restoring the UIViewControllers. My setup consists of a main view controller (loaded when the application starts) and then it can display one of two modal view controllers:
...........................MyAppDelegate..............................
.........................MainViewController...........................
....ModalViewController1.....ModalViewController2....
I originally tried to make the MainViewController/ModalViewController1/2 NSCoding compliant, so when my app terminates it archives MainViewController, which will then go on to archive its modal view controller (and they archive the backed instance). I was then going to restore the MainViewController when my application restarts, presenting the correct modal view controller within its initWithCoder: method, but it didn't really go to plan. I got errors from encoding view controllers that contained UIImage's (I wasn't trying to encode the UIImage directly since it doesn't support NSCoding, but when I call [super encodeWithCoder:coder] the UIViewController seems to try and encode them).
Am I going about this the right way and just messing something up or is there a different, more correct approach?
Thanks for your time,
-Ross