根據-[RLMCollectionChange modifications]
的文檔,它返回The indices in the new version of the collection which were modified.
。但是示例如下所示:RLMCollectionChange修改索引的修改錯誤描述?
[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]
返回。第二個沒有財產訪問它...
當然,你可以計算它。這就是我們現在要解決這個問題的方法。
因此,例如,在更新之前,我們有5個項目,我們得到了collectionChange,刪除前4個項目,並更改最後一個,我們將在索引0中進行修改?現在collectionChange說索引4的項目被修改... –