0
#import <UIKit/UIKit.h>

@interface FourthViewController : UIViewController{

//@interface FourthViewController : UITableViewController{

I want to update my tableview so I trying to use [self.tableView reloadData] but i cannot even type this line of code since I'm working in a UIViewController and the tableView property is for UITableViewController's only. So I tried to be smart and just change the UIViewController to UITableViewController but instead i got this error:

 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "b4k-XH-Uhj-view-V2h-dE-ixJ" nib but didn't get a UITableView.'

Imo this is strange since a UITableViewController would work for a tableView but not the other way around, but seams like i got it all wrong, or whats happening here? more code if you ask for it =) Thanks ahead.

EmilOoo
  • 3
  • 5

1 Answers1

0

A UITableViewController is really just a UIViewController that contains an outlet to a UITableView and implements the two tableview delegates: UITableViewDelegate and UITableViewDataSource.

You may want to consider replacing the viewcontroller instance in your nib file with a UITableViewController rather than a standard UIViewController.

Alternatively, you can manually adjust your ForthViewController instance by creating an outlet for the contained UITableView to expose the tableview as a property.

However, if you do it this way you'll also have to manually implement the two tableview delegates UITableViewDelegate and UITableViewDataSource somewhere (probably in ForthViewController) and manually associate the UITableView with these delegates.

pdriegen
  • 2,019
  • 1
  • 13
  • 19
  • Hi thanks for answering so quickly and explicit. I had began doing like this before I read your answer. And Im think this is your "Alternatively" way of doing it. @interface FourthViewController : UIViewController{ NSMutableArray * arrayKA; IBOutlet UITableView *TableKA; } I hockey up the IBOutlet with the tableView (dragging in the SB) I dont understand your last words "..and manually associate the UITableView with these delegates." Im new in Xcode but I think I can figure it out if you help me understand what u mean. Thanks again! Big help! – EmilOoo Apr 26 '12 at 14:21
  • @EmilOoo What I meant with "manually associate the UITableView with these delegates" that in your ForthViewController. implementation you'll have to explicitly state something like self.TableView.delegate = self; self.TableView.Datasource = self; Check the Apple docs for the methods you are required to implement when you use these delegates. Hope this helps! – pdriegen Apr 26 '12 at 17:32