You can subclass the object manager and override each method to call super
but wrapping the supplied failure callback in a custom block which adds your common logic.
One common action for all failed RestKit requests?
문제
Is it possible to set one common action for all failed requests in RestKit? I need to stop ajax spinner for those cases but I don't want to repeat this line of code in every callback (I have too many).
UPDATE: request example:
[_manager postObject:message path:@"/messages.json" parameters:nil success:^
(RKObjectRequestOperation *operation, RKMappingResult *result) {
Message *message = result.firstObject;
callback(message);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
failureCallback();
}];
And for errors I mean responses from server with status codes in 400..511 range
해결책
다른 팁
You can do it in completion block of Request Operations Queue, completion block is going to call up when queue operations are failed :
[objectManager enqueueBatchOfObjectRequestOperations:requestOperations progress: ^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) {
} completion: ^(NSArray *operations) {
//.. Stop Spinner Code
}];
제휴하지 않습니다 StackOverflow