Question

I am wondering if it's possible when we do a mapping to also include the foreign keys, meaning that if I use the mappingResult directly and I access some foreign Objects, CoreData won't have to always go and get that foreign key and put it in its cache..?

    [[RKObjectManager sharedManager] getObjectsAtPath:@"/api/rest/activities/" parameters:parameters success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult)
     {
     } failure:^(RKObjectRequestOperation *operation, NSError *error) {
     }];

For example in this case, an Activity object has a relation to an object User. If I loop through the mappingResult, and for each activity mapped I access the User object, right now, CoreData will need to go and fetch that User Object. Is it possible with RestKit to already use something like keyPaths (which we would normally use to prefetch the foreign objects?)

Is the only way to not have CoreData do this is to actually do NSFetchRequest?

Was it helpful?

Solution

That isn't the purpose of RestKit, or the objects it returns to you. While you could edit RestKit to do that there will be several cases where you don't want to.

It's best to keep the information about what you want to fetch and when separate to your RestKit usage / control code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top