Joe, please clarify use of AppDelegate


#1

Hi,

I am very confused about application flow control in iOS. In the first few chapters of the BNR book, AppDelegate is used to control overall application flow. However, this approach has been mercilessly rejected on the Apple Developer Forums as somehow oversimplifying the development process.

When I asked about the use of AppDelegate in the “Getting Started” forums, my question was quickly shot down, and I was directed to a previous thread that discussed these issues. My question was posted here:

devforums.apple.com/message/610045#610045

The other thread is posted here:

devforums.apple.com/message/593910

In that thread, Rufus (a very prolific commenter) wrote that “This is just flat wrong. Of course it works, and they apparently are trying to keep it simple, but it is going to totally confuse the hell out of all of their readers. Not right away, but later when the readers realize that you don’t use the app delegate as a view controller. Just the fact that this diagram shows labels hooked up to something that has no “view” property is BIZARRE.”

Rufus goes on to make some broader criticisms of BNR. When asked to suggest alternative books, he says “save your money” and directs folks to the Apple documentation.

I am soooooo confused. I have been trying to figure out other approaches for controlling application flow that would somehow be more appropriate, but none of the approaches seem to work. Can someone at BNR help the rest of us make sense of this controversy? Is this one of those classic programming holy wars in which it is hard to say who is correct? Or is Rufus correct in saying that the BNR approach will cause problems down the road?

Thanks in advance for any help you can give. Looking forward to the next edition.

Aaron


#2

I struggled myself with this a bit - particularly as I was trying to reconcile the rapidly-changing iOS bootstrap sequence with a not-that-old book by Matt Neuburg (excellent book by the way). Apple has been rather unrelenting in the pace of their development and it seems the printed-matter books have some trouble keeping up.

BNR’s just released iOS book is uptodate however, as is Matt Neuburg’s iOS 5 book. Here is a link I came across on the web:

oleb.net/blog/2012/02/app-launch … revisited/

Hope this helps.


#3

I can’t speak to the issues of Rufus, but I think that BNR’s use of the main app delegate in the first chapter was just a quick simple way to get you going and have an app right away. I am about to start working on chapter 16. Once I got past the first few chapters the book mainly only uses the main app delegate to set up the rootViewController, which is a class with a view that you create. Personally as long as you understand the bigger principles taught later in the book, I don’t see the harm in using the app delegate if your only making a simple app. Why complicate matters for such a simple app like chapter 1’s quiz.

As to the best guides, like others have suggested, it’s hard to say with is the best. I’ve actually been using the BNR book, the apple docs, several blogs and online tutorials as well. After all these guides teach you techniques and principles through the use of sample apps. Ultimately we all have to find our own way after that, unless copies of those apps are all you ever want to make. Just my two cents.