Can somebody explain this Objective C method declaration syntax
- by Doug R
I'm working through an iPhone development book* without really knowing Objective C. For the most part I'm able to follow what's going on, but there are a few method declarations like the one below that I'm having a bit of trouble parsing. For example:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section {
return [self.controllers count]; //controllers is an instance variable of type NSArray in this class
}
It looks this is a method called numberOfRowsInSection, and it returns an NSInteger, and takes an NSInteger as a parameter which is locally called 'section'. But I don't understand all the references to tableView, or why this takes a parameter when it is not used within the method. Can somebody clarify this? Thanks.
*p. 258, Beginning iPhone 3 Development, by Mark and LaMarche, published by Apress