Presence1 CS193P Stanford iPhone Dev

This was a great assignment for me.  I was able to get the PersonListViewController up and running.  I started by:

a) Adding the navigationController ivar in the delegate file (h) and adding its view to the window (m) as well as releasing it in dealloc.  Remember its EITHER OR.

You EITHER add the nav or tab or table VIEWCONTROLLER as a CONTROL in the XIB FILE.

OR you add it in code, by ALLOC/INITING it in the Class File.

b) then i added the IBAction in the PersonListViewController (h) and implementing that method (m) by instantiating the PersonDetailViewController, pushing it to the stack and releasing it.  Creating in my mind the VIEW CONTROLLERS RULE 1: Instantiate, Push and Release! In the viewDidLoad i just added bells and whistles like the title and an edit button i read about somewhere.

c) in the midst of all this, IB which is very helpful but AWFULLY CONFUSING, i learned that when i drag a ViewController onto my mainwindow.xib file, NOT THE WINDOW ITSELF, i must create the outlet connection to the delegate.  Furthermore, each new view controller must be classed for it to work and finally connect each Nib.  This is a simple task but obscure really, so i came up with the VIEW CONTROLLERS RULE 2: Create Class, Class it and Nib it!

d) Finally in the PersonDetailViewController, you add the iVars for logic and IBOutlets.  Create properties for some, but not others (why?) and any methods which here included the initWithNibName including the tag property whose button object had to be declared BEFORE calling initWithNibName.  Then in viewDidLoad code the logic including the if tag = 1 display this, not that.  The reason i see why you would only create properties and synthesize the imageview and int is because they form part of objects; UIImage and UIButton respectively whereas label and status are just variables given some value.

e) In IB, File Owner gets all the received actions and outlets to view.  Views get the outlets for buttons from being told which class that nib belongs to because in that class definition is where the IBOutlets are defined.  So basically the MainWindow.nib with, File Owner connects to delegate who connects to window and root navigation controller.  Each VC after that must belong to a class of its own and is connected up to the root navigation controller via the views which are pushed onto the main stack and added to the window of the MainWindow.nib.

Leave a Reply