RestKit delete old data from core data using setObjectMapping RestKit delete old data from core data using setObjectMapping xml xml

RestKit delete old data from core data using setObjectMapping


I haven't used Managed Objects before but the first thing to do here is to activate the restkit log over object mapping, network request and core data so you can check what is restkit getting from the server, how the mapping is working and how is fetching things from CD, so try the following:

//This can be added in your app delegateRKLogConfigureByName("RestKit/Network", RKLogLevelTrace);RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);RKLogConfigureByName("RestKit/CoreData", RKLogLevelTrace);

Looking at your code, you are using the same Path for both mappings in here:

// forResourcePathPattern:kWinSystemInfoXml[wsiObjectManager.mappingProvider setObjectMapping:audioSourcesMapping forResourcePathPattern:kWinSystemInfoXml                          withFetchRequestBlock:^NSFetchRequest *(NSString *resourcePath) {                             return [AudioSources fetchRequest];                         }];// forResourcePathPattern:kWinSystemInfoXml[wsiObjectManager.mappingProvider setObjectMapping:eventsMapping forResourcePathPattern:kWinSystemInfoXml                          withFetchRequestBlock:^NSFetchRequest *(NSString *resourcePath) {                             return [Events fetchRequest];                         }];

I think this can be causing a conflict, because RK choose one of both resources to be mapped to that path, so you should:

  1. Debug what is Core Data doing.
  2. Try to use a mapping for key path approach instead of resource path pattern, so RK doesn't get messed up, you need to define different ways to map each kind of object, right now I think the first one is being overwritten.

If that doesn't work you should post how are you deleting things in your code, maybe post all the code from your view controller. What can be happening is that the calls are being overwritten by your code somewhere. Are you using blocks?.

Hope that helps!