I'm confused as to what the first part of the following function declaration means. It adds an o开发者_开发知识库bject instance as part of the function definition.
E.g. In some sample code, class ItemsViewController which derives from UITableViewController has this function definition:
-(void) tableView:(UITableView*) aTableView didSelectRowAtIndexPath:(NSIndexPath*) indexPath
{ ... }
What exactly does the tableView:(UITableView*) aTableView
bit achieve?
It allows your delegate to serve as the delegate for multiple UITableView
s. When an event happens on any of the UITableView
s, the appropriate delegate method gets called and you can use the first parameter to determine which UITableView
the event relates to, and act accordingly. (Of course, your delegate has to have some way of knowing which view is which, for instance by having outlets to each of the views that it's the delegate for.)
精彩评论