Encoding NSViewController for Lion's user interface resume feature

前端 未结 2 916
感情败类
感情败类 2021-01-05 02:52

Any idea what are the best practices for archiving an NSViewController inside a window for resume (user interface preservation) purposes? I\'ve tried archiving

2条回答
  •  余生分开走
    2021-01-05 03:00

    I haven’t messed with restorable state much (Jonathon Mah did it for DL3) but if I were doing this I’d try deleting those two methods and implement +restorableStateKeyPaths, e.g.:

    + (NSArray *)restorableStateKeyPaths;
    {
        return @[@“contentViewController.firstInterestingStateProperty”, @“contentViewController.secondInterestingStateProperty”];
    }
    

    And just see if the machinery handled it all for me.

    + (NSArray *)restorableStateKeyPaths;
    

    Returns a set of key paths, representing paths of properties that should be persistent. The frameworks will observe these key paths via KVO and automatically persist their values as part of the persistent state, and restore them on relaunch. The values of the key paths should implement keyed archiving. The base implementation returns an empty array.

提交回复
热议问题