Created
July 12, 2013 16:02
-
-
Save swizzlr/5985563 to your computer and use it in GitHub Desktop.
Convenient keypath for finding whether a request completed successfully.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // AFHTTPRequestOperation+JLPOperationDidSucceed.h | |
| // | |
| // Created by @swizzlr on 11/07/2013. | |
| // BSD two clause license | |
| // | |
| @class AFHTTPRequestOperation; | |
| @interface AFHTTPRequestOperation (JLPOperationDidSucceed) | |
| -(BOOL)jlp_HTTPRequestOperationDidSucceed; | |
| @end | |
| /* | |
| Mostly for use as a keypath with collection operator for a collection AFHTTPRequestOperations, like so: | |
| [AFHTTPClient enqueueBatchOfHTTPRequestOperations:prioritySyncOperations progressBlock:nil completionBlock:^(NSArray *operations) { | |
| if (![[operations valueForKeyPath:@"@unionOfObjects.jlp_HTTPRequestOperationDidSucceed"] containsObject:@NO]) { | |
| //All operations succeeded: they finished, they had an acceptable status code and acceptable content type | |
| } else { | |
| //At least one didn't: display an error, requeue again... | |
| } | |
| }]; | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // AFHTTPRequestOperation+JLPOperationDidSucceed.m | |
| // | |
| // Created by @swizzlr on 11/07/2013. | |
| // BSD two clause license | |
| // | |
| #import "AFHTTPRequestOperation.h" | |
| #import "AFHTTPRequestOperation+JLPOperationDidSucceed.h" | |
| @implementation AFHTTPRequestOperation (JLPOperationDidSucceed) | |
| - (BOOL)jlp_HTTPRequestOperationDidSucceed { | |
| if (self.isFinished && self.hasAcceptableContentType && self.hasAcceptableStatusCode) { | |
| return YES; | |
| } | |
| return NO; | |
| } | |
| @end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
APPARENTLY YOU CAN JUST CHECK FOR AN ERROR
(!operation.error)