In CocoaTouch, tables have a delegate and a data source. The delegate sends and receives messages for the table view, and the data source controls the information that goes in the table and the table's headers and footers. The data source tells the table how many rows to draw, how many sections, what to put as the section titles, etcetera.
The table view queries the data source for how many rows to draw via the
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
method. Then, in the
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
method, the tableView asks for a cell to populate the table from the data source. When programming for the iPhone, tables are mostly populated by an array, a single variable (object) that contains many other variables (objects). You tell an array what object you want, by asking
object = [array objectAtIndex:INTEGER]; //where INTEGER is an unsigned (zero or greater, no minus)
what happened, is that your data source is expecting X number of objects for the table, and there are X-Y available. If it thinks there are 10, but there are only 9, when the table asks for the 10th object, you get a crash because there is no object to give.
look in your code for hte line
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
and see what that code is. Chances are you're providing the wrong data there.
Good luck
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…