У меня есть таблица, сгенерированная из массива NSManagedObjects.Это работает нормально, пока я не попытаюсь добавить дополнительную ячейку вверху таблицы.
Вот то, что я пытаюсь в данный момент:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
int menuLength = [mainMenu count] + 1;
return menuLength;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Check for reusable cell
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: @"UITableViewCell"];
// If no reusable cell, create one
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault
reuseIdentifier: @"UITableViewCell"] autorelease];
}
// Set the text on the cell with the genus name that is at the nth index of generaList
if ([indexPath row] == 0) {
[[cell textLabel] setText: @"All"];
} else {
NSManagedObject *filter = [mainMenu objectAtIndex: [indexPath row]];
[[cell textLabel] setText: [filter valueForKey: @"filter_label"]];
}
return cell;
}
Когда я пытаюсь прокрутитьв таблицу выдается следующее исключение:
'NSRangeException', причина: '* - [_ PFArray objectAtIndex:]: index (9) за пределами (9)'
Любая помощь будет высоко ценится!