Skip to content

Instantly share code, notes, and snippets.

@enigmaticape
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enigmaticape/a59d7de521015096949b to your computer and use it in GitHub Desktop.
Save enigmaticape/a59d7de521015096949b to your computer and use it in GitHub Desktop.
#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