RestKit/RestKit — Issue #404: Restkit response very slow always
Author: frapet
Created: 2011-10-13 09:25:25+00:00
State: open

Hi all,
I'm using RestKit and after I released the first version of my app I'm trying to improve the performance.

Now, I did several trials and I can't believe that each time I do a request I receive the response
back in the

- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects: (NSArray*)objects {

over 2 seconds always. I supposed it should be very fast, I should receive the response immediately after the request but it's not. I also tried testing the API request from the browser and it loads really really fast (milliseconds), so what happen?

So here my code:

///////////////////////////////////////
// MAPPING //
///////////////////////////////////////

NSLog(@"mapping");

RKManagedObjectMapping* contactMappingCD = [RKManagedObjectMapping mappingForClass:[RKCDContact class]];
[contactMappingCD setPrimaryKeyAttribute:@"internalID"];
[contactMappingCD mapKeyPath:@"internalID" toAttribute:@"internalID"];
[contactMappingCD mapKeyPath:@"lastModified" toAttribute:@"lastModified"];
[contactMappingCD mapKeyPath:@"firstName" toAttribute:@"firstName"];
[contactMappingCD mapKeyPath:@"lastName" toAttribute:@"lastName"];
[contactMappingCD mapKeyPath:@"userId" toAttribute:@"userId"];
[contactMappingCD mapKeyPath:@"companyName" toAttribute:@"companyName"];
[contactMappingCD mapKeyPath:@"middleName" toAttribute:@"middleName"];

// Register our mappings with the provider
[objectManager.mappingProvider setMapping:contactMappingCD forKeyPath:@"contact"];

///////////////////////////////////////
// REQUEST //
///////////////////////////////////////

int coreId = [[[NSUserDefaults standardUserDefaults] objectForKey:COREID] intValue];

//TO DO: Check active/unactive
NSString *resourcePath;

if (active==YES) {
resourcePath= [NSString stringWithFormat:@"/object/users/%i/contacts?active=true",coreId];
}else{
resourcePath= [NSString stringWithFormat:@"/object/users/%i/contacts?active=false",coreId];
}

//RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);

RKObjectLoader* loader = [objectManager loadObjectsAtResourcePath:resourcePath delegate:self];
[loader setUserData: [NSNumber numberWithInt:notificationUserData]];
NSLog(@"sending ");

Can anyone give me any tips/hints/suggestions ?
Thanks in advance