Update RestKit: loadObjectsAtResourcePath: usingBlock: do not save objects in cache

I am in a project where we use RestKit. We used version 0.9.2 until we decided to switch to 0.10.0. After some small changes in my code to make it compatible with the new version of RestKit, I found an error when I use loadObjectsAtResourcePath: usingBlock :. When I get a response in my deletion with objects object-loader: (void) objectLoader: (RKObjectLoader *) objectLoader didLoadObjects: (NSArray *), the array of objects has the correct objects, but they are not stored in the coreData cache. If I try to access them using fetch to coreData, I will not find them. Here is the code I'm using:

RestKit Configuration:

RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:[NSURL URLWithString:@"http://myweb.com/web/app.php/ws"]];
objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = NO;
objectManager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"db.sqlite"];

    RKManagedObjectMapping* boAccount    = [RKManagedObjectMapping mappingForClass:[BOAccount class] inManagedObjectStore:objectManager.objectStore];
boAccount.primaryKeyAttribute        = @"boAccountID";
[boAccount mapKeyPathsToAttributes:  @"id", @"boAccountID",
                                     @"created_at", @"createDate",
                                     @"date_expiration", @"expirationDate",
                                     @"date_billing", @"billingDate",
                                     @"nb_authorized_devices", @"numberOfAuthorizedDevices",
 nil];
[objectManager.mappingProvider addObjectMapping:boAccount];
[objectManager.mappingProvider setMapping:boAccount forKeyPath:@"account"];

A call to load loadObjectsAtResourcePath: usingBlock:

[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/connection" usingBlock:^(RKObjectLoader *loader){
    RKParams *params= [RKParams params];

    //[params setValue:_password.text forParam:@"password"]; 
    [params setValue:[Encrypt encryptWithPublicKeyMessage:_password.text] forParam:@"password"];
    [params setValue:_email.text forParam:@"email"];
    [params setValue:udid forParam:@"udid"];
    [params setValue:name forParam:@"name"];

    loader.delegate = self;
    loader.params= params;
    loader.method= RKRequestMethodPOST;

} ];

- (void) objectLoaderDidFinishLoading: (RKObjectLoader *) objectLoader {

BOAccount* account;
NSArray* accounts = [BOAccount allObjects];
account = [accounts objectAtIndex:0];

}

. - (void) objectLoaderDidFinishLoading: (RKObjectLoader *) objectLoader {, . , , , , . , , objectLoaderDidFinishLoading .

- , ? !

: , iPad, ... , . , , RestKit ?

+3
1

CoreData:

    loader.onDidLoadObjects = ^(NSArray *objects) {
        // Save:
        NSError* error = nil;
        [[RKObjectManager sharedManager].objectStore.managedObjectContextForCurrentThread save:&error];
        if (error) {
            NSLog(@"Save error: %@", error);
        }
     }
+3

All Articles