0

I have this boolean in my AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];

        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

        UIViewController *viewController = // determine the initial view controller here and instantiate it with [storyboard instantiateViewControllerWithIdentifier:<storyboard id>];

        self.window.rootViewController = viewController;
        [self.window makeKeyAndVisible];

        return YES;
    }

I'm getting an error on the *storyboard but what I am mainly trying to do is initialize the application in a different view controller than the main one. I have all the view controllers with IDs (such as the one I want to launch is named "Home"). How would I correctly write this bool if say my ViewController ID was home?

My main.m:

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

The nil I get is whenever I try to go back to the original Home page from my Contact list page so it crashes and highlights the nil line. Both this and the above delegate bool are giving me issues. Any clarification would be very much appreciated, thanks.

2014-09-20 18:38:40.281 iContact Professional[4932:176723] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'MainStoryboard' in bundle NSBundle (loaded)' * First throw call stack: ( 0 CoreFoundation 0x000000010f4153f5 exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010f0aebb7 objc_exception_throw + 45 2 UIKit 0x000000010fef7cf0 -[UIStoryboard name] + 0 3 iSociety Professional 0x000000010e7ce03e -[AppDelegate application:didFinishLaunchingWithOptions:] + 382 4 UIKit 0x000000010f9a75a5 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 234 5 UIKit 0x000000010f9a80ec -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2463 6 UIKit 0x000000010f9aae5c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1350 7 UIKit 0x000000010f9a9d22 -[UIApplication workspaceDidEndTransaction:] + 179 8 FrontBoardServices 0x00000001138e52a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16 9 CoreFoundation 0x000000010f34aabc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 12 10 CoreFoundation 0x000000010f340805 __CFRunLoopDoBlocks + 341 11 CoreFoundation 0x000000010f33ffc3 __CFRunLoopRun + 851 12 CoreFoundation 0x000000010f33fa06 CFRunLoopRunSpecific + 470 13 UIKit 0x000000010f9a9799 -[UIApplication _run] + 413 14 UIKit 0x000000010f9ac550 UIApplicationMain + 1282 15 iSociety Professional 0x000000010e7cf8e3 main + 115 16 libdyld.dylib 0x0000000111d21145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

I referred to this link for help:

Programmatically set the initial view controller using Storyboards

Community
  • 1
  • 1
Gav
  • 1
  • 2

0 Answers0