Last active
August 29, 2015 14:01
-
-
Save enigmaticape/a59d7de521015096949b to your computer and use it in GitHub Desktop.
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
#import "SKRequest+Blocks.h" | |
#import <objc/runtime.h> | |
static char const * const completion_key = "completion"; | |
@implementation SKRequest (Blocks) | |
- (void) | |
request :(SKRequest *) request | |
didFailWithError:(NSError *) error | |
{ | |
SKRequestCompletion completion = ( | |
objc_getAssociatedObject( | |
self, | |
completion_key | |
) | |
); | |
completion( request, error ); | |
} | |
- (void) | |
requestDidFinish:(SKRequest *) request | |
{ | |
SKRequestCompletion completion = ( | |
objc_getAssociatedObject( | |
self, | |
completion_key | |
) | |
); | |
completion( request, nil ); | |
} | |
- (void) | |
startWithCompletion:(SKRequestCompletion) completion | |
{ | |
objc_setAssociatedObject( | |
self, | |
completion_key, | |
completion, | |
OBJC_ASSOCIATION_RETAIN_NONATOMIC | |
); | |
self.delegate = self; | |
[self start]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment