[Issue #33] Changing return type of class method object contructors from id to an actual instance of that class
This commit is contained in:
parent
f422cafe14
commit
db4c852e3d
10 changed files with 54 additions and 59 deletions
|
|
@ -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.
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,10 +143,10 @@ static NSThread *_networkRequestThread = nil;
|
|||
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) {
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
@interface AFImageCache : NSCache
|
||||
|
||||
+ (id)sharedImageCache;
|
||||
+ (AFImageCache *)sharedImageCache;
|
||||
|
||||
- (UIImage *)cachedImageForRequest:(NSURLRequest *)urlRequest
|
||||
cacheName:(NSString *)cacheName;
|
||||
|
|
|
|||
|
|
@ -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, ^{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,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) {
|
||||
|
|
@ -46,13 +44,13 @@ static dispatch_queue_t image_request_operation_processing_queue() {
|
|||
} 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) {
|
||||
|
|
@ -81,8 +79,6 @@ static dispatch_queue_t image_request_operation_processing_queue() {
|
|||
}
|
||||
});
|
||||
}];
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -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.
|
||||
|
|
@ -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;
|
||||
|
||||
|
||||
///----------------------------------
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
@ -57,13 +57,13 @@ static dispatch_queue_t json_request_operation_processing_queue() {
|
|||
}];
|
||||
}
|
||||
|
||||
+ (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];
|
||||
|
|
|
|||
|
|
@ -27,5 +27,5 @@ extern NSString * const kAFGowallaClientID;
|
|||
extern NSString * const kAFGowallaBaseURLString;
|
||||
|
||||
@interface AFGowallaAPIClient : AFRestClient
|
||||
+ (id)sharedClient;
|
||||
+ (AFGowallaAPIClient *)sharedClient;
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -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]];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue