У меня есть таблица с объектами, добавленными с помощью NSArray, которая называется listOfConjProcedures. Я хочу использовать элемент управления вставкой, который отображается над верхней строкой таблицы, чтобы добавить строки в мою таблицу при нажатии кнопки редактирования в контроллере UInavigation, и я не могу найтихороший пример кода.Функция редактирования выглядит следующим образом:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if ([tableView isEditing])
return [listOfConjProcedures count] + 1;
else
return [listOfConjProcedures count];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[listOfConjProcedures removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
Я не знаю, как перейти к функции вставки, чтобы ввести новую строку при нажатии кнопки редактирования (в нижней части опубликованного кода).Заранее спасибо.