0

I looked on stackoverflow and found this topic:

More than one RKObjectManager at a time (RestKit)

Unfortunately it is not anymore accurate with the current RetKit as the method:

[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/whatever" delegate:self]

returns a void.

So how can I distinguish the different objectLoaders in the method:

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

Or is there a better method to have multiple requests with different URLs? As if I only use one manager, only the last requests call gets executed, and I need to set the manager manually to null to work the second time.

Any help on how to best manage multiple request calls in a short amount of time and to distinguish between them would be great.

Community
  • 1
  • 1
Aranir
  • 828
  • 1
  • 10
  • 21

2 Answers2

0

Couldn't you have different delegates for different "loadObjects" calls?

Dan Morrow
  • 4,433
  • 2
  • 31
  • 45
  • Well this is certainly one solution, but what if the delegate needs to respond to multiple objectLoader requests differently? – Aranir Oct 10 '12 at 08:47
0

After trying many different things I finally found the new equivalent in the documentation.

The trick is to use a block and assing the loader.userData inside the block:

[self.manager loadObjectsAtResourcePath:filter usingBlock: ^(RKObjectLoader *loader) {
        loader.userData = @"identifier";
        loader.delegate = self;
    }];

Where the self.manager just a normal RKObjectManager with appropriate mapping is.

Aranir
  • 828
  • 1
  • 10
  • 21