Skip to content

Commit

Permalink
[Issue domesticcatsoftware#33] Changing return type of class method o…
Browse files Browse the repository at this point in the history
…bject contructors from id to an actual instance of that class
  • Loading branch information
mattt committed Sep 21, 2011
1 parent f422caf commit db4c852
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 59 deletions.
12 changes: 6 additions & 6 deletions AFNetworking/AFHTTPRequestOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ extern NSString * const AFHTTPOperationDidFinishNotification;
@return A new HTTP request operation
*/
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion;
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion;

/**
Creates and returns an `AFHTTPRequestOperation` object and sets the specified input and output streams, and completion callback.
Expand All @@ -97,10 +97,10 @@ extern NSString * const AFHTTPOperationDidFinishNotification;
@return A new HTTP request operation
*/
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
inputStream:(NSInputStream *)inputStream
outputStream:(NSOutputStream *)outputStream
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion;
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
inputStream:(NSInputStream *)inputStream
outputStream:(NSOutputStream *)outputStream
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion;

///---------------------------------
/// @name Setting Progress Callbacks
Expand Down
12 changes: 6 additions & 6 deletions AFNetworking/AFHTTPRequestOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ + (NSThread *)networkRequestThread {
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];
Expand All @@ -143,10 +143,10 @@ + (id)operationWithRequest:(NSURLRequest *)urlRequest
return operation;
}

+ (id)operationWithRequest:(NSURLRequest *)urlRequest
inputStream:(NSInputStream *)inputStream
outputStream:(NSOutputStream *)outputStream
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
inputStream:(NSInputStream *)inputStream
outputStream:(NSOutputStream *)outputStream
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion
{
NSMutableURLRequest *mutableURLRequest = [[urlRequest mutableCopy] autorelease];
if (inputStream) {
Expand Down Expand Up @@ -175,7 +175,7 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest {

self.request = urlRequest;

self.runLoopModes = [NSSet setWithObjects:NSRunLoopCommonModes, nil];
self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes];

self.state = AFHTTPOperationReadyState;

Expand Down
2 changes: 1 addition & 1 deletion AFNetworking/AFImageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

@interface AFImageCache : NSCache

+ (id)sharedImageCache;
+ (AFImageCache *)sharedImageCache;

- (UIImage *)cachedImageForRequest:(NSURLRequest *)urlRequest
cacheName:(NSString *)cacheName;
Expand Down
4 changes: 2 additions & 2 deletions AFNetworking/AFImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

@implementation AFImageCache

+ (id)sharedImageCache {
static NSCache *_sharedImageCache = nil;
+ (AFImageCache *)sharedImageCache {
static AFImageCache *_sharedImageCache = nil;
static dispatch_once_t oncePredicate;

dispatch_once(&oncePredicate, ^{
Expand Down
14 changes: 7 additions & 7 deletions AFNetworking/AFImageRequestOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@

@interface AFImageRequestOperation : AFHTTPRequestOperation

+ (id)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(UIImage *image))success;
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(UIImage *image))success;

+ (id)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 *)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;

@end
20 changes: 8 additions & 12 deletions AFNetworking/AFImageRequestOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -36,8 +34,8 @@ static dispatch_queue_t image_request_operation_processing_queue() {

@implementation AFImageRequestOperation

+ (id)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(UIImage *image))success
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(UIImage *image))success
{
return [self operationWithRequest:urlRequest imageProcessingBlock:nil cacheName:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
if (success) {
Expand All @@ -46,13 +44,13 @@ + (id)operationWithRequest:(NSURLRequest *)urlRequest
} failure:nil];
}

+ (id)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 *)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) {
Expand Down Expand Up @@ -81,8 +79,6 @@ + (id)operationWithRequest:(NSURLRequest *)urlRequest
}
});
}];

return operation;
}

@end
20 changes: 10 additions & 10 deletions AFNetworking/AFJSONRequestOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
@return A new JSON request operation
*/
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success;
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success;

/**
Creates and returns an `AFJSONRequestOperation` object and sets the specified success and failure callbacks.
Expand All @@ -56,9 +56,9 @@
@return A new JSON request operation
*/
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success
failure:(void (^)(NSError *error))failure;
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success
failure:(void (^)(NSError *error))failure;

/**
Creates and returns an `AFJSONRequestOperation` object and sets the specified success and failure callbacks, as well as the status codes and content types that are acceptable for a successful request.
Expand All @@ -71,11 +71,11 @@
@return A new JSON request operation
*/
+ (id)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;
+ (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;


///----------------------------------
Expand Down
22 changes: 11 additions & 11 deletions AFNetworking/AFJSONRequestOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ static dispatch_queue_t json_request_operation_processing_queue() {

@implementation AFJSONRequestOperation

+ (id)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success
{
return [self operationWithRequest:urlRequest success:success failure:nil];
}

+ (id)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success
failure:(void (^)(NSError *error))failure
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(id JSON))success
failure:(void (^)(NSError *error))failure
{
return [self operationWithRequest:urlRequest acceptableStatusCodes:[self defaultAcceptableStatusCodes] acceptableContentTypes:[self defaultAcceptableContentTypes] success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
if (success) {
Expand All @@ -57,13 +57,13 @@ + (id)operationWithRequest:(NSURLRequest *)urlRequest
}];
}

+ (id)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
+ (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];
Expand Down
2 changes: 1 addition & 1 deletion Example/Classes/AFGowallaAPIClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ extern NSString * const kAFGowallaClientID;
extern NSString * const kAFGowallaBaseURLString;

@interface AFGowallaAPIClient : AFRestClient
+ (id)sharedClient;
+ (AFGowallaAPIClient *)sharedClient;
@end
5 changes: 2 additions & 3 deletions Example/Classes/AFGowallaAPIClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@

#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";

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]];
Expand Down

0 comments on commit db4c852

Please sign in to comment.