0

I have several RestKit gets that all use the same format:

[[RKClient sharedClient] get:endString queryParameters:params delegate:self];

I have a masterMethod that essentially refreshes all my user's restful data that looks like this

-(void)masterMethod
{
[self get1];
[self get2];
[self get3];
[self get4];
[self get5];
}

Where all the gets are in the same format as the one above. All of this code is in a class that includes the delegate method:

- (void)request:(RKRequest*)request didLoadResponse:(RKResponse*)response

However, I think something is going wrong when I try to call all give gets in the same method. It's as though the delegate didLoadResponse & didRecieveResponse methods are overlapping or getting release or something. Is there a way to make a master queue to handle this huge call? Or is something else going wrong.

I'm getting a BAD_ACCESS error somewhere in the masterMethod call.

Thanks, any help greatly appreciated.

Eric
  • 4,063
  • 2
  • 27
  • 49

1 Answers1

0

What are you getting? If you're pulling down objects you should us the isKindOfClass method to distinguish the objects in objectLoader:didLoadObjects and set appropriately.

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

    if ([[objects objectAtIndex:0] isKindOfClass:[Apple class]]) {

        Apple *apple = [objects objectAtIndex:0];

    }
    else if ([[objects objectAtIndex:0] isKindOfClass:[Banana class]]) {

        Banana *banana = [objects objectAtIndex:0];

    }
}

If you're pulling data from the request response, look into setting userdata on the request object, then checking the userdata in request:didLoadResponse. For more information see RestKit: distinguish multiple requests in didLoadResponse:.

Community
  • 1
  • 1
Kyle Clegg
  • 38,547
  • 26
  • 130
  • 141
  • It's not that I want to distinguish which object is being received as much as much as make sure the didLoadResponse:(RKResponse*)response are all called separately. – Eric Aug 29 '12 at 16:57
  • 1
    They are not called separately. RestKit calls are all performed asynchronously. If you need to make a synchronous call you should probably rethink the logic of your calls. That being said, it can be done using blocks. Here is one example. http://stackoverflow.com/a/11836265/654870 – Kyle Clegg Aug 29 '12 at 18:09
  • why is there no get with Block that has params? – Eric Aug 29 '12 at 18:25
  • it does but for some reason, restKit doesn't have queryParameters option in their get that includes a block. – Eric Aug 29 '12 at 20:41
  • Ok I understand what you're asking. Not sure about that. Perhaps you could append the params to the end of the URL in this case? – Kyle Clegg Aug 29 '12 at 20:43
  • http://stackoverflow.com/questions/12185251/restkit-get-with-params-block-with-shared-client – Eric Aug 29 '12 at 20:44