Can somebody explain this Objective C method declaration syntax

Posted by Doug R on Stack Overflow See other posts from Stack Overflow or by Doug R
Published on 2010-05-26T02:18:02Z Indexed on 2010/05/26 2:21 UTC
Read the original article Hit count: 388

Filed under:

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

© Stack Overflow or respective owner

Related posts about objective-c