Search code examples
iosdatabaserestkit

using restkit do you have to remap EVERYTHING each time something changes?


Right now I have a server that formats my data exactly how restkit wants it, and restkit just takes it and directly maps it to coredata.

This works fine, but when I start to accumulate a lot of data it becomes slow.

For example, I have one object called "stories" and each story contains an array of "posts". each time a new "post" gets added, I regenerate the "story" object to which the new post belongs to, and return the story object to the user for restkit to map. As a story starts to accumulate many posts, this process becomes very slow for restkit. I would prefer a way to just send back new posts, and then tell restkit "hey, add this post to the array of posts on this story", which is in contrast to what I do now which is more like "replace this story with this one I just returned, which includes all posts including any new or updated ones".

Is this possible within restkit? Am I better served just manipulating core data myself to support updates?


Solution

  • Yes, it's possible.

    You can look at 'foreign key mapping' to connect your new posts to the existing story. The most important part is to set the relationship assignment type to Union because the default is replace.