views:

237

answers:

1

I'm creating a new subclass of UITableViewController, and with it the below default implementation. It doesn't compile , cause clearly there is no variable called "number of sections", what's going on here ? The error is : "expected expression before '<' token"

#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return number of sections;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return <#number of rows in section#>;
}
A: 

The strings number of sections and <#number of rows in section#> need to be actual integers, corresponding with the number of sections and rows in your data source.

For example, if you have an array of five objects that you want to represent with a table view, and you want them all to go into one section, you need to return 1 from -numberOfSectionsInTableView: and 5 from -tableView:numberOfRowsInSection:.

You may want to read Apple's Table View Programming Guide for iOS to get some familiarity with how table views work, before writing any code.

Alex Reynolds
Yes, I know that, I just assumed that auto generated implementation should always compile.Guess I was wrong. Thanks!
Idan