From 3c459ed7dfefe90fa0e69b3825094fb5d39aaf8b Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 3 May 2015 20:25:40 -0700 Subject: [PATCH] improve state restoration, leverage restoration IDs more --- Blog/AppDelegate.m | 9 ++++++--- Blog/Base.lproj/Main.storyboard | 14 +++++++------- Blog/EditorViewController.m | 3 --- Blog/PostsViewController.m | 3 --- Blog/PreviewViewController.m | 34 +++++++++------------------------ 5 files changed, 22 insertions(+), 41 deletions(-) diff --git a/Blog/AppDelegate.m b/Blog/AppDelegate.m index 7136cb9..3a10dec 100644 --- a/Blog/AppDelegate.m +++ b/Blog/AppDelegate.m @@ -72,9 +72,12 @@ - (EditorViewController *)editorViewController { UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; UINavigationController *navigationController = splitViewController.viewControllers.firstObject; - navigationController = navigationController.viewControllers.lastObject; - EditorViewController *editorViewController = (EditorViewController *)navigationController.viewControllers.firstObject; - return editorViewController; + if (navigationController.viewControllers.count > 1) { + navigationController = navigationController.viewControllers.lastObject; + EditorViewController *editorViewController = (EditorViewController *)navigationController.viewControllers.firstObject; + return editorViewController; + } + return nil; } - (ModelStore *)newModelStoreWithPath:(NSString *)dbPath { diff --git a/Blog/Base.lproj/Main.storyboard b/Blog/Base.lproj/Main.storyboard index 9153356..08bb683 100644 --- a/Blog/Base.lproj/Main.storyboard +++ b/Blog/Base.lproj/Main.storyboard @@ -73,7 +73,7 @@ - -