根据-[RLMCollectionChange modifications]
的文档,它返回The indices in the new version of the collection which were modified.
。但是示例如下所示:
[tv beginUpdates];
[tv deleteRowsAtIndexPaths:[changes deletionsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic];
[tv insertRowsAtIndexPaths:[changes insertionsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic];
[tv reloadRowsAtIndexPaths:[changes modificationsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic];
[tv endUpdates];
UITableView
需要旧集合中的索引。这是不好的描述吗?
另一个问题是如何在新集合中获取索引?
调试器显示RLMCollectionChange
包含_indices.modifications
和_indices.modifications_new
。看起来第一个是-[RLMCollectionChange modifications]
返回的内容。第二个没有财产来访问它......
当然你可以计算出来。这就是我们现在必须解决这个问题的方法。
答案 0 :(得分:0)
表视图需要一个新索引。因为在beginUpdates
和endUpdates
之间进行操作是为了使表视图的状态遵循更改的模型。
此外,新的和旧的都与modifications
无关。 modifications
是对象的位置不会改变,只有属性会改变。如果属性将其位置更改为对象,则将其视为"移动"而不是修改。因此,它会转换为insertion
和deletion
,而不是modification
。