iwasrobbed
iwasrobbed

Reputation: 46703

iPhone Advanced table view cells example

I have been going through and re-creating Apple's "Advanced Table View Cells" example to better understand everything. I have done everything, but somehow missed one detail and I can't figure it out.

If you launch their example (http://developer.apple.com/iphone/library/samplecode/AdvancedTableViewCells/Introduction/Intro.html) and open up the RootViewController.xib file, they have a "tableView" outlet on the inspector that is linked to File's Owner. For whatever reason, I can't get that to show up on my version.

My code is almost verbatim of Apple's, so what am I missing? Did I not declare that somewhere or doesn't that get taken from the RootViewController.m file?

Upvotes: 3

Views: 2672

Answers (3)

iwasrobbed
iwasrobbed

Reputation: 46703

So after being bugged by this problem for a while... I figured out a workaround. Please note that all of my code was exactly the same as Apple's and yet IB would never show a tableView outlet (as if it wasn't subclassing UITableView properly in my UINavigation Controller).

Essentially all I did was change the subclass from a UITableViewController to a UIViewController and then called the delegate and datasource protocols. After doing that and creating my own tableView outlet, I was finally able to hook up the tableView and get it working as it should.

@interface RootViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {

used to be

@interface RootViewController : UITableViewController {

Upvotes: 0

Nico
Nico

Reputation: 253

Did you set File's Owner to the class of the object you are trying to link to?

To check if you did so, open your xib file, and see if the File's Owner type is the class you want to link to.

If it doesn't and reads something else like NSObject, open the inspector, go to the Identity tab (Cmd+4), click File's Owner and in the Class Identity section, there's a dropdown menu with the list of classes in your project. Select your UITableViewController subclass and then try to make the link.

Upvotes: 2

Andiih
Andiih

Reputation: 12413

Their RootViewController subclasses UITableViewController. It is this that generates the tableView outlet.

Upvotes: 1

Related Questions