我正在尝试找到一个代码示例,该示例显示如何使用核心数据处理 tableView 中的移动/重新排列单元格。我可以移动元素数组。如何更新核心数据(Mybase)?
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription* entityDescription = [NSEntityDescription entityForName:@"Mybase"
inManagedObjectContext:self.objectContext];
[fetchRequest setEntity:entityDescription];
empArray = [(NSArray*)[self.objectContext executeFetchRequest:fetchRequest error:nil] mutableCopy];
Mybase *employee = [empArray objectAtIndex:fromIndexPath.row];
[empArray removeObject: employee];
[empArray insertObject: employee atIndex:toIndexPath.row]
}