Strategy? statusField is in viewController, not appDelegate


In case any of my fellow sojourners are wondering the same thing, I’ll ask here. I started the book using Xcode 4.2 and ARC, having decided the unspoken challenge is to use the differences between the book and the present tools as a learning opportunity. But over and over we create a new “Window-based” project where outlets are connected to the appDelegate; and as near as I can wrangle Xcode 4.2 that just isn’t going to happen in a ‘single view’ app. (I did download Joe’s blank window-based project, but felt grungy using it :slight_smile: )

If there’s a way to control drag from a UILabel to an appDelegate, I’m all ears.

Which leaves the strategy question: How do you wire up the UILabel in the View to “outlets” in the AppDelegate? I suppose you can use the “viewDidLoad” time to communicate pointers between a viewController and an appDelegate. But would it be “better” to go an NSNotification route? So in this example if your netService:didNotResolve the appDelegate could post a notification that the viewController was listening for, and who in turn would update the UILabel with the “Could not resolve service.” message?


I’ve taken a hybrid strategy. For a start, I have been using XCode 4.2 but not been using ARC - I’m not certain if it supports older devices, and reasoned that it’s probably easier to go from knowing manual memory management to using ARC than vice versa. I also used the provided “window template” for the first half of the book or so, until there came a stage where I felt I understood what was going on and the differences between that and the “Single view application” (although I basically start everything with empty project now, as it is easier).

I’ve solved this specific problem in a probably bad and non-generic way; I create and load the view controller, but wanted to keep all the net stuff on the application delegate (rather than backing myself into a corner in the view delegate). So, I store a pointer “mainView” to the view on the app delegate. Then, instead of:

I simply do:

This seemed the minimal route to achieving this without possibly diverging too much from the book for the later parts to get difficult (I have no idea what the next chapter will bring). Notifications sounds a bit more general, but in a proper application I guess you’d have the networking stuff handled by a model class so would need more thinking.


Thanks, misnomer: I appreciate hearing about your approach. I think since posting the question I’ve learned more about using observers to do this work. I also started a project using the storyboard model of Xcode 4.2, and find that for some reason to just make sense. I realize it makes sense because of all the ground work Joe laid in this book, but I had a certain sense of relief as I set about a storyboard and actually felt confident in what I was doing and how to do it.