views:

331

answers:

3

I'm working on my first iPhone app and have been able to get most things done. There's one problem that I've run into a few times and I want to understand the issue better.

In XCode, if I go File->New File->UIViewController subclass and make sure that both UITableViewController subclass and With XIB for user interface are checked, then it creates a MyViewController.h, MyViewController.m, and MyViewController.xib.

When I look at this xib in Interface Builder, you can see that the File Owner has an Outlet called view that is already connected to the UITableView. No problem. This all makes sense and is great.

My issue comes when I've changed the type of my class (or done something else) and some how the "view" Outlet goes away. I get an error saying "view not showing up in file owner outlet".

My question is how do I then reconnect the UITableView as the "view" of the ViewController when the Outlet goes away? The only way I've been able to get it to work is to literally start over with a new xib/viewcontroller.

+1  A: 

That "view" outlet should be coming from the parent class (in your case UITableViewController).

What do you mean by change type? If you are changing the name of your class, try using Edit > Refactor with the class name selected in Xcode.

gerry3
A: 

In the "Document" window (cmnd + 0) - control + click on file's owner, a weird looking line thing will show up. drag the mouse over to your view and release. a little drop down will come up from which you can set the view to the File's Owner View outlet.

bpapa
I know how to make the connections generally, the problem is that somehow my view controller no longer has a "view" outlet after I do something (not sure exactly what). It's happened to me twice.
philfreo
A: 

Typically the "view" outlet would be coming from the parent class (UITableViewController). If it's not showing up, then Interface Builder is not connected to your project than this could happen instead.

My problem was due to an edge case as described here: http://stackoverflow.com/questions/1568930/interface-builder-and-xcode-integration-not-working

philfreo