It looks like you're new here. If you want to get involved, click one of these buttons!
- (void)encodeRestorableStateWithCoder:(NSCoder *)coder
- (void)restoreStateWithCoder:(NSCoder *)coder
and/or I can implement these NSWindowDelegate methods:
- (void)window:(NSWindow *)window willEncodeRestorableState:(NSCoder *)state
- (void)window:(NSWindow *)window didDecodeRestorableState:(NSCoder *)state
In either case, seems like I would encode/decode any properties and view controllers at this time. I haven't seen the NSResponder methods get called yet under any circumstances. The NSWindowDelegate ones get called semi-regularly, but I haven't quite figured out what to do there. For example, in the encode one, I do this:
- (void)window:(NSWindow *)window
willEncodeRestorableState:(NSCoder *)state
{
[state encodeObject:[self splitViewController] forKey:@"SplitViewController"];
}
This method runs, but the NSCoding methods in the splitViewController never run. So if something is being encoded, I can't tell. When I go to decode:
- (void)window:(NSWindow *)window
didDecodeRestorableState:(NSCoder *)state
{
if ([state containsValueForKey:@"splitViewController"])
{
[self setSplitViewController:[state decodeObjectForKey:@"SplitViewController"]];
}
}
...the test passes, so there is something there, but if I check the property value after decoding, it is nil. Even if it wasn't nil, this view controller is not the same one that gets created in windowDidLoad, so it seems like there would be a disconnect between this view controller and the (presumably) automatically restored view.+ (NSArray *)restorableStateKeyPaths
{
return [NSArray arrayWithObjects:@"splitViewController", nil];
}
...and it does get called pretty reliably at launch, but I can't tell what it's doing for me. Seems like these things should have save/load pairs, and I'm not really understanding what the opposite method of this is, if there is one.