Search
Rich's Mad Rants
Powered by Squarespace

Creating iOS 5 Apps Discussion > Applications are expected to have a root view controller at the end of applicationĀ launch

If you happen to be getting this error "Applications are expected to have a root view controller at the end of application launch" after changing the class from UITabBarController to TabBarController in your Xcode while running the app, simply remove the stub

- (void)loadView
{
}

Its added by default when you first create the class. Im not sure why it works and why not in first place, but I just found out and Im still learning myself!

cheers!
G

March 18, 2012 | Unregistered CommenterGuru

I'm not sure why the template would have added a loadView stub. It probably has something to do with the particular version you're using or the options you selected. I just tested creating a tab bar controller subclass using Xcode 4.3.1, and it didn't add it.

The "Applications are expected to have a root view controller..." warnings are relatively new. Technically we're giving it a root view controller--the tab bar controller. However, overriding the superclass's loadView method is undoubtedly keeping it from being initialized properly, and that's what's causing the problems.

In a nutshell, we can override loadView to programmatically create our views. The default implementation will try to open the controller's nib file to create the views.

So far so good, but we're subclassing UITabBarController here. The tab bar controller already knows how to set up its view hierarchy. I don't know if it does this programmatically or through a nib file--and ultimately it doesn't matter. The important point is, by adding a loadView stub, we're basically short circuiting our superclass's ability to set up the views, and we end up with a tab bar controller with no view hierarchy.

I suspect the loadView stub is a bug. An Apple engineer probably thought it would be a nice feature--but it sure seems like it will cause more problems than it solves. So I suspect it was added to a version of Xcode, then quickly removed with the next version. At least, I cannot seem to trigger it with the current version.

I hope that helps.

-Rich-

March 21, 2012 | Registered CommenterRichard Warren

Thanks Rich for detail explanation. Reading your book by far very exciting and explanation you did about approach you took in design is superb.

I do get errors (and i'm still on chapter 3!)but mostly because of my typos or missed something in Interface Builder but finding the solution to those small problem itself is challenging and learning in itself.

But the one above Im not sure how I got it or as you said some specific setting in XCode but I will keep an eye next time creating any new view or controllers. But certainly it was added for me by xcode 4.3 developer release and will download 4.3.1 today!

Guru

March 22, 2012 | Unregistered CommenterGuru

It really sounds like something they added to the 4.3 developer preview, then removed for the final release. And, Apple has done this in the past. Before iOS 5 came out, one of the developer previews had project templates for UIDocument-based applications. They didn't work right, and they were removed with the next release. I feel like Apple Engineers may have a bit of free reign to test things out in the developer previews--so we shouldn't rely on them too heavily.

I'm glad you're enjoying the book. Let me know if you have any questions. Also, if you find the book helpful or informative, it would really help me out if you could head over to Amazon and give it a good rating or write a short review. That really helps draw more attention to the book.

More importantly, if you have any other questions as you go along, please don't hesitate to ask. I can't always answer right away, but I'm trying to keep up with issues as they arise. Also, be sure to check out the FAQ for any errata. There are a few small mistakes in the text--so if you're having trouble, it might not be your fault.

-Rich-

March 22, 2012 | Registered CommenterRichard Warren

Sure I will write a review on amazon.ca. I think (if Im not wrong) I heard you on Podcast (iDeveloperTV) with Scotty and heard about the book there. And bought it immediately. It was a month before or so and so far going slow but steady. !

And Im using Version 4.3 (4E71d) and I checked again by adding a ViewController class (w/o XIB) it doest add that stub, but not sure to tell XCode that Im using storyboard and i will eventually tie up the things thru' IB.

And thanks Im looking forward to post my more (and may be silly) doubts on this forum. :D

March 22, 2012 | Unregistered CommenterGuru

oops typo again. It DOES add the stub loadView.

March 22, 2012 | Unregistered CommenterGuru