Which class must I extend?

(I am developing an app that presents chat messages in a table. But, this chat can't be started by the user, when the user receives a message the chat view opens. So, I made this code:

- (void) newMessageReceived:(NSMutableDictionary *)message
{
   General *general = [General sharedManager];
   NSString *firstmessage=[message objectForKey:@"msg"];
   NSString *from=[message objectForKey:@"sender"];    
   NSArray *listItems = [from componentsSeparatedByString:@"@"];
   NSString *fromsplit=[listItems objectAtIndex:0];
   general.firstmess=firstmessage;
   general.firstfrom=fromsplit;
   NSLog(@"Mensaje recibido: %@ de %@", [message objectForKey:@"msg"], fromsplit);

   ChatViewController *cvc=[[ChatViewController alloc]initWithNibName:@"Chat" bundle:nil];

   [[self navigationController]pushViewController:cvc animated:YES];
}

Everything is ok, until here. The ChatViewController extends UITableViewController. But, when a message is received i get the following exception:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "Chat" nib but didn't get a UITableView.

Then, i try to change the class extended to UIViewController (did this to check that the program enters the numberOfRowsInSection method) and then i receive:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ChatViewController setTableViewStyle:]: unrecognized selector sent to instance 0x9863200'

I think that solving the first exception would fix my problem. Any help?

Thank you.

Answers


In the second exception i think you have called [self setTableViewStyle:] method, while   

you have made it UIViewController.

So try to call this method by tableViewOutlet.

[tableView setTableViewStyle:];

Hope this will help you


Solved it. i click the .xib file, under "objects", clicked "View". And then, in the Identity Inspector (the third one, starting from the left), in Custom Class, set it to UITableView. It was simply "View" before. And then, everything worked fine.


Need Your Help

WCF service is instansiating on each call

c# .net wcf web-services

I have a WCF service on the client side and a wcf service on the server side.