I'm accessing an API using the latest version of RestKit, and am pulling down some "Event" objects.
I have two different API endpoints:
1. "All Events"
2. "This user's events"
The Events from endpoint #2 are a subset of those from endpoint #1.
At the moment, I've created two different CoreData entities, one for each endpoint. This works, but is inefficient - there's duplication of those events that are in the subset.
What I'd like to do is use endpoint #1 to pull down all the events, and then use endpoint #2 to flag those events (from endpoint #1) that relate to this user.
Is it possible to use RKEntityMapping to map an arbitrary value (flag) into received objects - I could therefore flag the user's events as they arrive, but still put them into the same CoreData entities as the superset of events.
Or any other suggestions?
In fact, what you propose is the only way this should be done. I do not know about RestKit, but you can simply first fetch the user's events, insert into Core Data, and then fetch all events and only insert those that are not contained in the user events. If you have two arrays of dictionaries or managed objects a simple predicate would do: