[Issue #33] Changing return type of class method object contructors from id to an actual instance of that class

This commit is contained in:
Mattt Thompson 2011-09-21 15:33:20 -05:00
parent f422cafe14
commit db4c852e3d
10 changed files with 54 additions and 59 deletions

View file

@ -82,7 +82,7 @@ extern NSString * const AFHTTPOperationDidFinishNotification;
@return A new HTTP request operation
*/
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion;
/**
@ -97,7 +97,7 @@ extern NSString * const AFHTTPOperationDidFinishNotification;
@return A new HTTP request operation
*/
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
inputStream:(NSInputStream *)inputStream
outputStream:(NSOutputStream *)outputStream
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion;

View file

@ -134,7 +134,7 @@ static NSThread *_networkRequestThread = nil;
return _networkRequestThread;
}
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion
{
AFHTTPRequestOperation *operation = [[[self alloc] initWithRequest:urlRequest] autorelease];
@ -143,7 +143,7 @@ static NSThread *_networkRequestThread = nil;
return operation;
}
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
inputStream:(NSInputStream *)inputStream
outputStream:(NSOutputStream *)outputStream
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion
@ -175,7 +175,7 @@ static NSThread *_networkRequestThread = nil;
self.request = urlRequest;
self.runLoopModes = [NSSet setWithObjects:NSRunLoopCommonModes, nil];
self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes];
self.state = AFHTTPOperationReadyState;

View file

@ -25,7 +25,7 @@
@interface AFImageCache : NSCache
+ (id)sharedImageCache;
+ (AFImageCache *)sharedImageCache;
- (UIImage *)cachedImageForRequest:(NSURLRequest *)urlRequest
cacheName:(NSString *)cacheName;

View file

@ -28,8 +28,8 @@ static inline NSString * AFImageCacheKey(NSURLRequest *urlRequest, NSString *cac
@implementation AFImageCache
+ (id)sharedImageCache {
static NSCache *_sharedImageCache = nil;
+ (AFImageCache *)sharedImageCache {
static AFImageCache *_sharedImageCache = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{

View file

@ -26,10 +26,10 @@
@interface AFImageRequestOperation : AFHTTPRequestOperation
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(UIImage *image))success;
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
cacheName:(NSString *)cacheNameOrNil
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success

View file

@ -23,8 +23,6 @@
#import "AFImageRequestOperation.h"
#import "AFImageCache.h"
#import "UIImage+AFNetworking.h"
static dispatch_queue_t af_image_request_operation_processing_queue;
static dispatch_queue_t image_request_operation_processing_queue() {
if (af_image_request_operation_processing_queue == NULL) {
@ -36,7 +34,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
@implementation AFImageRequestOperation
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(UIImage *image))success
{
return [self operationWithRequest:urlRequest imageProcessingBlock:nil cacheName:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
@ -46,13 +44,13 @@ static dispatch_queue_t image_request_operation_processing_queue() {
} failure:nil];
}
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
cacheName:(NSString *)cacheNameOrNil
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
{
AFImageRequestOperation *operation = [self operationWithRequest:urlRequest completion:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error) {
return (AFImageRequestOperation *)[self operationWithRequest:urlRequest completion:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error) {
dispatch_async(image_request_operation_processing_queue(), ^(void) {
if (error) {
if (failure) {
@ -81,8 +79,6 @@ static dispatch_queue_t image_request_operation_processing_queue() {
}
});
}];
return operation;
}
@end

View file

@ -40,7 +40,7 @@
@return A new JSON request operation
*/
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success;
/**
@ -56,7 +56,7 @@
@return A new JSON request operation
*/
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success
failure:(void (^)(NSError *error))failure;
@ -71,7 +71,7 @@
@return A new JSON request operation
*/
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
acceptableStatusCodes:(NSIndexSet *)acceptableStatusCodes
acceptableContentTypes:(NSSet *)acceptableContentTypes
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success

View file

@ -36,13 +36,13 @@ static dispatch_queue_t json_request_operation_processing_queue() {
@implementation AFJSONRequestOperation
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success
{
return [self operationWithRequest:urlRequest success:success failure:nil];
}
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success
failure:(void (^)(NSError *error))failure
{
@ -57,13 +57,13 @@ static dispatch_queue_t json_request_operation_processing_queue() {
}];
}
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
acceptableStatusCodes:(NSIndexSet *)acceptableStatusCodes
acceptableContentTypes:(NSSet *)acceptableContentTypes
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
{
return [self operationWithRequest:urlRequest completion:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error) {
return (AFJSONRequestOperation *)[self operationWithRequest:urlRequest completion:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error) {
if (!error) {
if (acceptableStatusCodes && ![acceptableStatusCodes containsIndex:[response statusCode]]) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];

View file

@ -27,5 +27,5 @@ extern NSString * const kAFGowallaClientID;
extern NSString * const kAFGowallaBaseURLString;
@interface AFGowallaAPIClient : AFRestClient
+ (id)sharedClient;
+ (AFGowallaAPIClient *)sharedClient;
@end

View file

@ -22,8 +22,6 @@
#import "AFGowallaAPIClient.h"
static AFGowallaAPIClient *_sharedClient = nil;
// Replace this with your own API Key, available at http://api.gowalla.com/api/keys/
NSString * const kAFGowallaClientID = @"e7ccb7d3d2414eb2af4663fc91eb2793";
@ -31,7 +29,8 @@ NSString * const kAFGowallaBaseURLString = @"https://api.gowalla.com/";
@implementation AFGowallaAPIClient
+ (id)sharedClient {
+ (AFGowallaAPIClient *)sharedClient {
static AFGowallaAPIClient *_sharedClient = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
_sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:kAFGowallaBaseURLString]];