I have a tab view that loads a table view for each of the tabs
First tab interface declares UITableView *tableView;
Second tab interface declares UITableView *favTableView;
When declaring the number of rows for the second table this works:
- (NSInteger)tableView:(UITableView *)favTableView numberOfRowsInSection:(NSInteger)section {
return [favList count];
}
But if I change it to:
- (NSInteger)favTableView:(UITableView *)favTableView numberOfRowsInSection:(NSInteger)section {
return [favList count];
}
the app crashes when I try to load the second tab
Is my mistake (a) not understanding which is a variable/reserved word, (b) giving each table a unique identifier ie favTableView, instead of reusing tableView.
Also the second table doesn’t have a title bar
The delegate method you must implement is
In this method prototype,
tableView:(note the colon) is a fixed name you cannot change. The second instance oftableViewis simply a local variable name that has meaning within the method. The following would also be valid:The delegate method names are what they are. You cannot decide that you want the delegate method names to be something else, or how would
UITableViewknow what methods to call when it needed information from its delegate?So, for your table favTableView, if you specified the object that implements the above delegate method as favTableView’s delegate, then when called the local variable
tvwould in fact be the same asfavTableView.I can see where you’d be confused about this. The SDK uses ‘tableView’ for a lot of things: method prototype placeholder names, variable names, and who knows what else. It boils down to being able to read and understand Objective-C method signatures. 🙂 It’s a little strange, until you get used to it.