У меня есть UITableView с пользовательскими ячейками.Когда я нажимаю на редактирование, TableView переходит в режим редактирования, как и должно быть.Я могу перемещать ячейки, удалять их и сохранять результаты в Core Data Entities.Новый порядок ячеек сохраняется в Базовых данных, и все это работает.
Однако я бы хотел, чтобы новая позиция ячейки отражалась либо после перемещения, либо после нажатия «Готово».Значение в метке всегда будет строкой + 1, независимо от того, куда они перемещены.Как мне повторно предоставить
Каков наилучший способ добиться этого?
Заранее спасибо
-Paul
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
ProfileItems *profileItems = [ingredients objectAtIndex:fromIndexPath.row];
// NSLog(@"profileItems: %@", profileItems);
[ingredients removeObjectAtIndex:fromIndexPath.row];
[ingredients insertObject:profileItems atIndex:toIndexPath.row];
NSInteger start = fromIndexPath.row;
NSLog(@"start: %d", start);
NSInteger end = toIndexPath.row;
NSLog(@"end: %d", end);
// Update Core Data to reflect the cell's new position in the TableView
profileItems.profileItemsSongOrder = [NSNumber numberWithInteger:end + 1];
// This won't work becuase there is no cell referenced in here. Do I have to point to it again? If so how?
cell.profileItemsSongNumberLabel.text = [NSString stringWithFormat:@"%@",profileItems.profileItemsSongOrder];
}