Application windows are expected to have a root view cont

I am incredibly confused, and If I am doing anything not according to the book I deserve a big slap in the face for moaning about this.

I am adding all the code from page 247 to AppDelegate.m, and as soon as I run the app in iOS simulator I get a SIGABRT error in Main.m:

2016-03-27 18:17:48.019 Idoodle[2519:394907] *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UIApplication.m:3401 2016-03-27 18:17:48.021 Idoodle[2519:394907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch' *** First throw call stack: ( 0 CoreFoundation 0x000000010cf3fd85 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010c9b3deb objc_exception_throw + 48 2 CoreFoundation 0x000000010cf3fbea +[NSException raise:format:arguments:] + 106 3 Foundation 0x000000010c5fdd5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198 4 UIKit 0x000000010d2f4ab6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 3127 5 UIKit 0x000000010d2f1714 -[UIApplication workspaceDidEndTransaction:] + 188 6 FrontBoardServices 0x000000010fd5e8c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24 7 FrontBoardServices 0x000000010fd5e741 -[FBSSerialQueue _performNext] + 178 8 FrontBoardServices 0x000000010fd5eaca -[FBSSerialQueue _performNextFromRunLoopSource] + 45 9 CoreFoundation 0x000000010ce65301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 10 CoreFoundation 0x000000010ce5b22c __CFRunLoopDoSources0 + 556 11 CoreFoundation 0x000000010ce5a6e3 __CFRunLoopRun + 867 12 CoreFoundation 0x000000010ce5a0f8 CFRunLoopRunSpecific + 488 13 UIKit 0x000000010d2f0f21 -[UIApplication _run] + 402 14 UIKit 0x000000010d2f5f09 UIApplicationMain + 171 15 Idofuckingdoodle 0x000000010c4b29af main + 111 16 libdyld.dylib 0x000000010f71992d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

Although Xcode 7 doesn’t contain Empty application project, I even downloaded it online just to check if that was the problem. The application didn’ t work with an Empty project or single view.

It appears that the app has a problem with this statement if it helps, although it’s only the third one I can get the application to launch if I comment out all code including/following this statement:

I would appreciate a fast response as I have been reading this book on and off for years and I finally want to finish it, and I don’t want to have to put it down again!!

Running Xcode 7.3, El Capitan 10.11.4 (Hackintosh)

You probably don’t have a root view controller, which the window object wants to be present. In the past, iOS was not very fussy about this, but nowadays it is.

Here is an example of how to create a view controller and install it as the root view controller for the window object.

//
//  AppDelegate.m
//
#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSLog (@"%s", __PRETTY_FUNCTION__);
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    ViewController * viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

[Become a competent programmer faster than you can imagine: pretty-function.org]