Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

[iphone sdk] use view controllers in IB, or forget they exist?

So here is the thing... most of Apple's sample code either does not use IB, or it uses it sparingly.

However, I've heard that Apple suggests using IB to develop apps. Honestly, I'm a little confused as to what I'm supposed to do with the view controllers that are available via the IB pallet. I can't find any Apple tutorials that show how to build a complex application using IB to define the view controllers. However there must be some way to utilize them, I just wonder if it will save me time or cost me time in the long run.... hard to know what to invest my (limited) time learning right now.

What do you guys suggest for someone new to Cocoa?

Mac OS X (10.5.4)

Posted on Aug 23, 2008 3:33 AM

Reply
4 replies

Aug 23, 2008 6:16 AM in response to cerebrosoft

I use the view controllers to better structure my IB stuff. I put the views inside their controllers that are of the correct user-defined classes. This way I can easily view in IB all the different links with outlets and actions, properly self-contained within a controller+view(s) group.

Similarly, I add an object in IB for every class that interacts with UI stuff so that I can link sources, outlets and actions on them properly (for example, a data source class for a table view).

Also let's say you want to build a navigation controller-based app. In IB it's very easy to set up the basic framework. Then you go in xcode and build up the functionality without having to generate all these things procedurally.

That said, doing everything procedurally is fine too.

Aug 23, 2008 11:43 AM in response to H Asseily

Thanks... so lets say I add a "Table View Controller" to a xib file. What have I really done? Is a UITableViewController created behind the scenes somewhere? and I've have to set this on an outlet in my app delegate or somewhere? If so, I assume the "Table View Controller" merely a place holder and I can or should change the class name to some concrete implementation that I've already written?

Aug 23, 2008 12:25 PM in response to cerebrosoft

You're getting there..

Things you put your nib (xib) file are real objects (a UITableView, a UIButton, etc). All objects which get archived (or serialized/saved) to a binary format for your app.

In your code, such as a ViewController, you have IBOutlet objects, which represent the elements in your nib. These are pointers to the objects in the nib file. So in your controller class, if you send a message to myTableView (which you defined in your ViewController .h file), then you really are sending the message to the UITableView in the nib.

Of course, in order for these to talk to each other, you must first link them up in IB. But that's the gist of it.

[iphone sdk] use view controllers in IB, or forget they exist?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.