我在这里有一个错误,我找不到它所以我希望你敏锐的眼睛会!
我正在使用带有tableView的FRC.FRC是按keyPath排序的部分,然后按"displayOrder"排序 - 通常.
每个部分中的详细信息"displayOrder"从1开始,因此当我插入项目时,在另一个方法中,它将转到该部分的索引0.
我想循环遍历受影响的部分,并从1开始重新分配"displayOrder".
在重新订购期间,代码适用于:在任何部分内重新排序,因为重新排序的单元格向上移动而不是向下移动.
代码不适用于...单击单元格但不移动它.代码因某种原因改变了顺序,从而改变了单元格的顺序. - 当我单击一个单元格时,它与其上方的其他单元格在同一部分重新排序.
我以前有这个工作,我不知道发生了什么.
谢谢你的帮助.
-Edited-
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
NSError *error = nil;
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
TheDetail *fromThing = [self.fetchedResultsController objectAtIndexPath:fromIndexPath];
TheDetail *toThing = [self.fetchedResultsController objectAtIndexPath:toIndexPath];
NSPredicate *catetgoryPredicate = [NSPredicate predicateWithFormat:@"relationshipToTheCategory.name == %@", fromThing.relationshipToTheCategory.name];
NSMutableArray *allThings = [[[self.fetchedResultsController fetchedObjects] filteredArrayUsingPredicate:catetgoryPredicate] mutableCopy];
NSPredicate *fromPredicate = [NSPredicate predicateWithFormat:@"relationshipToTheSection.name == %@", fromThing.relationshipToTheSection.name];
NSPredicate *toPredicate = [NSPredicate predicateWithFormat:@"relationshipToTheSection.name == %@", toThing.relationshipToTheSection.name];
[allThings removeObject:fromThing];
[allThings insertObject:fromThing atIndex:toIndexPath.row];
//if the sections are NOT …Run Code Online (Sandbox Code Playgroud)