Cesar Oyarzun
Cesar Oyarzun

Reputation: 169

Restkit [operation waitUntilFinished] not working

I'm using reskit inside my cocoapods library I have an example library where I reference my own library to make the call, so when I make the call from IOS example code I get empty result. This is my code.

RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[responseDescriptor]];
[operation setCompletionBlockWithSuccess:^(RKObjectRequestOperation                  *operation, RKMappingResult *result) {
    device = result.firstObject;
} failure:nil];

[operation start];
[operation waitUntilFinished];

return device;

Upvotes: 0

Views: 118

Answers (1)

Wain
Wain

Reputation: 119031

Operation completion blocks are called after the operation is complete, but I think also after the operation has finished, which is what you wait for. You can check this with log statements. As such the device hasn't been set.

You don't actually need the block, just remove it and access the mappingResult directly after you're told the operation is complete.

Upvotes: 0

Related Questions