2014-04-20 156 views
0

如果self.objects数组是只读的,如何处理PFQueryTableView中单元格的重新排序?重新排序PFQueryTableView中的单元格?

我可以让表进入编辑模式,我甚至可以重新排列单元格,但我不知道如何处理委托方法中的更改。我试图从self.objects数组中创建一个NSMutableArray,但我不知道要在解析中更新对象。这是我已经尝试过:

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { 

    NSMutableArray *array = [[NSMutableArray alloc]initWithArray:self.objects]; 

    PFObject *movedObject = array[fromIndexPath.row]; 

    [array removeObjectAtIndex:fromIndexPath.row]; 
    [array insertObject:movedObject atIndex:toIndexPath.row]; 


    //Then trying to reassign the updated mutable array to the self.objects array is not possible because its read only. 

} 

任何帮助将不胜感激。

回答

0

尽管我意识到处理单元格与解析对象重新排列的方法是单独更新重新排列的对象,而不是尝试创建更新的数组。

+0

你可以与你分享你重新安排的对象,让他们保持这种方式?试图在PFQueryTableViewController的子类上执行此操作。谢谢! –

相关问题