mirror of
https://github.com/samsonjs/samhuri.net-ios.git
synced 2026-04-27 15:07:44 +00:00
wire up the blog controller properly after restoring state
This commit is contained in:
parent
7ebd8d2ddb
commit
e4638495c2
1 changed files with 26 additions and 10 deletions
|
|
@ -19,21 +19,28 @@
|
||||||
|
|
||||||
@interface AppDelegate () <UISplitViewControllerDelegate>
|
@interface AppDelegate () <UISplitViewControllerDelegate>
|
||||||
|
|
||||||
|
@property (nonatomic, readonly, strong) BlogController *blogController;
|
||||||
|
@property (nonatomic, readonly, strong) PostsViewController *postsViewController;
|
||||||
|
@property (nonatomic, readonly, strong) EditorViewController *editorViewController;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AppDelegate
|
@implementation AppDelegate
|
||||||
|
|
||||||
|
@synthesize blogController = _blogController;
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||||
[self configureCodeInjection];
|
[self setupCodeInjection];
|
||||||
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
|
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
|
||||||
UINavigationController *navigationController = splitViewController.viewControllers.lastObject;
|
UINavigationController *navigationController = splitViewController.viewControllers.lastObject;
|
||||||
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
|
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
|
||||||
splitViewController.delegate = self;
|
splitViewController.delegate = self;
|
||||||
[self setupBlogController];
|
self.postsViewController.blogController = self.blogController;
|
||||||
|
self.editorViewController.blogController = self.blogController;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)configureCodeInjection {
|
- (void)setupCodeInjection {
|
||||||
__block BOOL codeInjectionEnabled = NO;
|
__block BOOL codeInjectionEnabled = NO;
|
||||||
[[[NSProcessInfo processInfo] arguments] enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
|
[[[NSProcessInfo processInfo] arguments] enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
|
||||||
if ([obj isEqual:@"EnableCodeInjection"]) {
|
if ([obj isEqual:@"EnableCodeInjection"]) {
|
||||||
|
|
@ -45,6 +52,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BlogController *)blogController {
|
||||||
|
if (!_blogController) {
|
||||||
|
NSString *cachesPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject;
|
||||||
|
NSString *dbPath = [cachesPath stringByAppendingPathComponent:@"blog.sqlite"];
|
||||||
|
ModelStore *store = [self newModelStoreWithPath:dbPath];
|
||||||
|
_blogController = [self newBlogControllerWithModelStore:store rootURL:@"http://ocean.samhuri.net:6706/"];
|
||||||
|
}
|
||||||
|
return _blogController;
|
||||||
|
}
|
||||||
|
|
||||||
- (PostsViewController *)postsViewController {
|
- (PostsViewController *)postsViewController {
|
||||||
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
|
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
|
||||||
UINavigationController *navigationController = splitViewController.viewControllers.firstObject;
|
UINavigationController *navigationController = splitViewController.viewControllers.firstObject;
|
||||||
|
|
@ -52,13 +69,12 @@
|
||||||
return postsViewController;
|
return postsViewController;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setupBlogController {
|
- (EditorViewController *)editorViewController {
|
||||||
NSString *cachesPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject;
|
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
|
||||||
NSString *dbPath = [cachesPath stringByAppendingPathComponent:@"blog.sqlite"];
|
UINavigationController *navigationController = splitViewController.viewControllers.firstObject;
|
||||||
ModelStore *store = [self newModelStoreWithPath:dbPath];
|
navigationController = navigationController.viewControllers.lastObject;
|
||||||
BlogController *blogController = [self newBlogControllerWithModelStore:store rootURL:@"http://ocean.samhuri.net:6706/"];
|
EditorViewController *editorViewController = (EditorViewController *)navigationController.viewControllers.firstObject;
|
||||||
|
return editorViewController;
|
||||||
[self postsViewController].blogController = blogController;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ModelStore *)newModelStoreWithPath:(NSString *)dbPath {
|
- (ModelStore *)newModelStoreWithPath:(NSString *)dbPath {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue