XCode7.0: Insert Button Not Responding


I built the iTahDoodle app using xcode7 Beta. Couple of issues i encountered

  1. If i copy code as-is, the app throws error
    "Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Application windows are expected to have a root view controller at the end of application launch’"
    i googled and was able to overcome this issue by adding following line of code (highlighted) :
    CGRect winFrame = [[UIScreen mainScreen] bounds];
    UIWindow *theWindow = [[UIWindow alloc] initWithFrame];
    self.window = theWindow;
    self.window.rootViewController = [[UIViewController alloc] init];

  2. After the step 1 update app runs fine but when ever i click on the “Insert” button, NOTHING happens. I googled and tried to put the

    self.insertButton.enabled = YES;

    but this did not help me either.
    Can anyone tell me if this is the issue with xcode 7 beta or do i need to add few more lines of code. Quick response will be much appreciated.

P.S. The keyboard soft or hard was not working as well, so had to add code below, (ie) becomeFirstResponder to atleast start typing in the textbox or else it was behaving like readonly
self.taskField = [[UITextField alloc] initWithFrame:fieldFrame];
self.taskField.borderStyle = UITextBorderStyleRoundedRect;
self.taskField.placeholder = @“Type a task, tap insert”;
[self.taskField becomeFirstResponder];


Guys, any feedback from anyone as to why my insert UI button does not work. I am stuck on this for last 3 days, googled almost everything regarding this still no luck. Its just that i dont want to quit on this issue and move forward.


If you don’t mind taking the trouble of uploading a .zip of your project folder somewhere and linking it here, I’ll have a look, and explain the issue if I find it.


Hi Mikey,
Thanks for your response. Below is the link to drop box where i have uploaded my code. Please let me know your feedback. It may be a silly mistake but this one i will never forget for sure :slight_smile:

P.S. i am using xcode 7.3 (beta)


There’s a ‘workaround’ answer and a ‘real’ answer to the problem.

Workaround first:

In AppDelegate.m, add the subviews to self.window.rootViewController.view instead of self.window:

[code] // Add our three UI elements to the window

[self.window.rootViewController.view addSubview:self.insertButton];

[self.window.rootViewController.view addSubview:self.taskTable];
[self.window.rootViewController.view addSubview:self.taskField];

// [self.window bringSubviewToFront:self.insertButton];[/code]

You can also get rid of the bringSubviewToFront: call, as I did above.

The real answer to the problem is this:

This chapter was designed to just tease a bit about iOS development. We have a whole book about real iOS development. In order to keep the chapter brief, we avoided the use of view-controller-based architecture for this chapter’s app, leaving discussion of view controllers and how they work for the actual iOS Programming Guide. Since then, iOS has come to require view-controller-based architecture, and now crashes your app if you don’t use view controllers, as you experienced.

The fallout is that while the workaround I mentioned will cause the app to build and run without crashing, the reality is that this chapter needs to be rewritten to use the more modern and correct patterns/paradigms, such as view controllers and autolayout.

Since you’re learning Objective-C right now, I suspect your goal is to then move on to iOS development. Any iOS book worth it’s mettle will cover those topics in detail.

The takeaway is to enjoy this chapter as a brief foray into iOS development, but not to treat it as a correct or modern approach to iOS development.

I hope that helps.

Don't work with new Xcode 7 version

Your lines of code works like charm, eventhough for some reason the performance has become very very sluggish. I wont spend more time on this as you correctly assumed, i am on journey of learning iOS development and want to master objective C first (although it sounds outdate after swift) but im a old school guy who wants to have basics in place :slight_smile:. That being said, once i am done with ObjC i have your BNR iOS Development and then Advanced iOS dev manual which i got from the training session from BNR. Wish me luck and thanks for responding and solving quickly. It motivates me more.


Rock on. In all honesty, I think the most skilled iOS developers of the next several years will need to know both Objective-C and Swift, because they’re still so closely tied to one another. But take your time and learn them one at a time. For now, enjoy your Obj-C journey.

Cheers and happy coding!



I still struggle with that issue. Tried adding root view controller, even with a for loop for every window. But nothing…

I use XCODE Version 7.2.1 and choose “iOS Single View Application” as the option “Empty Application” isn’t available anymore…

thanks in advance…


Thanks a lot! It works for me!


I’m running Xcode version 8.3.3 and this workaround needed one extra step to work for me, as described in this other post:


Hello. In BNRAppDelegate.m you have to put this code in didFinishLaunchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
// Create and configure the UIWindow instance
    // CGRect is a struct with an origin (x, y) and a size (width, height)
    CGRect winFrame = [[UIScreen mainScreen] bounds];
    UIWindow *theWindow = [[UIWindow alloc] initWithFrame:winFrame];
    self.window = theWindow;
    // Finalize the window and put it on the screen
    self.window.rootViewController = [[UIViewController alloc] init];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

......... Setting up controls

    // Add our three UI elements to the window
    [self.window.rootViewController.view addSubview:self.taskTable];
    [self.window.rootViewController.view addSubview:self.taskField];
    [self.window.rootViewController.view addSubview:self.insertButton];

  return YES;