It looks like you need to maintain your own flattened data source. Perhaps the following will be done:
When the NSFetchedResultController tells you that a new Entity1 been added, you insert Entity1 and its associated Entity2 into say, _flattenedArray so that it looks like this:
[<Entity1>, <related Entity2>, <related Entity2>...]
Where you insert them is up to you - it pretty much comes down to:
- build a subarray containing the new
Entity1 and its associated Entity2 objects - decide where to insert a new subarray in
_flattenedArray . - calling
reloadData or some other means to inform tableView of new data
When deleting an Entity1 object Entity1 delete it and all subsequent Entity2 objects until you encounter the end of _flattenedArray or move to another Entity1 object. This assumes that Entity2 never a top-level object. If you need to delete only those Entity2 objects in the relation.
When Entity1 gets or loses Entity2 , you can first remove Entity1 from _flattenedArray and then reinsert it. If this is too effective, do a merge instead.
freespace
source share