From 63dc2a05eddbd902fb222a393db3e54ccd6a52ae Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 1 Jun 2011 10:36:43 -0500 Subject: [PATCH] Adding AFImageRequestOperation +operationWithRequest:callback: --- AFImageRequestOperation.h | 3 ++- AFImageRequestOperation.m | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/AFImageRequestOperation.h b/AFImageRequestOperation.h index a02e7ba..9e6f9d8 100644 --- a/AFImageRequestOperation.h +++ b/AFImageRequestOperation.h @@ -41,7 +41,8 @@ typedef enum { @property (nonatomic, retain) AFImageRequestOperationCallback *callback; -- (id)initWithRequest:(NSURLRequest *)someRequest callback:(AFImageRequestOperationCallback *)someCallback; ++ (id)operationWithRequest:(NSURLRequest *)urlRequest callback:(AFImageRequestOperationCallback *)callback; +- (id)initWithRequest:(NSURLRequest *)urlRequest callback:(AFImageRequestOperationCallback *)callback; @end diff --git a/AFImageRequestOperation.m b/AFImageRequestOperation.m index 376fc73..2c6ba4b 100644 --- a/AFImageRequestOperation.m +++ b/AFImageRequestOperation.m @@ -35,8 +35,12 @@ static inline CGSize kAFImageRequestRoundedCornerRadii(CGSize imageSize) { @implementation AFImageRequestOperation @synthesize callback = _callback; -- (id)initWithRequest:(NSURLRequest *)someRequest callback:(AFImageRequestOperationCallback *)someCallback { - self = [super initWithRequest:someRequest]; ++ (id)operationWithRequest:(NSURLRequest *)urlRequest callback:(AFImageRequestOperationCallback *)callback { + return [[self alloc] initWithRequest:urlRequest callback:callback]; +} + +- (id)initWithRequest:(NSURLRequest *)urlRequest callback:(AFImageRequestOperationCallback *)callback { + self = [super initWithRequest:urlRequest]; if (!self) { return nil; } @@ -47,7 +51,7 @@ static inline CGSize kAFImageRequestRoundedCornerRadii(CGSize imageSize) { [statusCodes addIndexesInRange:NSMakeRange(200, 100)]; self.acceptableStatusCodes = statusCodes; self.acceptableContentTypes = [NSSet setWithObjects:@"image/png", @"image/jpeg", @"image/pjpeg", @"image/gif", @"application/x-0", nil]; - self.callback = someCallback; + self.callback = callback; if (self.callback) { self.runLoopModes = [NSSet setWithObjects:NSRunLoopCommonModes, NSDefaultRunLoopMode, nil];