I've been trying to preserve the state of my iPhone application by serializing my main UITabBarController using [NSKeyedArchiver archiveRootObject:toFile:], but I'm running into difficulties.
First I had a problem with UIImage, since it doesn't implement the NSCoding protocol, but I solved that by making an extension category for UIImage that stores and retrieves the raw image data.
The problem I'm stuck on now is that my view controllers aren't there when I restore from the archive. I have UINavigationControllers in each of my tabs, and when I restore, the UINavigationItems are still there -- I can use the Back buttons and so on to change them -- but the view controllers are just gone.
I see that UINavigationController's viewControllers property is marked "(nonatomic, copy)"; does this mean that when you archive a UINavigationController, it doesn't include its stack of view controllers? If so, how can I get around this? I first thought I would override the NSCoding methods for UINavigationController, but this screws up initialization from the NIB file.
I'm a little perturbed that I've been having this much difficulty preserving app state -- I figured it was a common enough use case that it would be straightforward to implement. Am I missing something here?