[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,7 +82,7 @@ extern NSString * const AFHTTPOperationDidFinishNotification;
|
||||||
|
|
||||||
@return A new HTTP request operation
|
@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;
|
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
|
@return A new HTTP request operation
|
||||||
*/
|
*/
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
inputStream:(NSInputStream *)inputStream
|
inputStream:(NSInputStream *)inputStream
|
||||||
outputStream:(NSOutputStream *)outputStream
|
outputStream:(NSOutputStream *)outputStream
|
||||||
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion;
|
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion;
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ static NSThread *_networkRequestThread = nil;
|
||||||
return _networkRequestThread;
|
return _networkRequestThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion
|
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion
|
||||||
{
|
{
|
||||||
AFHTTPRequestOperation *operation = [[[self alloc] initWithRequest:urlRequest] autorelease];
|
AFHTTPRequestOperation *operation = [[[self alloc] initWithRequest:urlRequest] autorelease];
|
||||||
|
|
@ -143,7 +143,7 @@ static NSThread *_networkRequestThread = nil;
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
inputStream:(NSInputStream *)inputStream
|
inputStream:(NSInputStream *)inputStream
|
||||||
outputStream:(NSOutputStream *)outputStream
|
outputStream:(NSOutputStream *)outputStream
|
||||||
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion
|
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion
|
||||||
|
|
@ -175,7 +175,7 @@ static NSThread *_networkRequestThread = nil;
|
||||||
|
|
||||||
self.request = urlRequest;
|
self.request = urlRequest;
|
||||||
|
|
||||||
self.runLoopModes = [NSSet setWithObjects:NSRunLoopCommonModes, nil];
|
self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes];
|
||||||
|
|
||||||
self.state = AFHTTPOperationReadyState;
|
self.state = AFHTTPOperationReadyState;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
@interface AFImageCache : NSCache
|
@interface AFImageCache : NSCache
|
||||||
|
|
||||||
+ (id)sharedImageCache;
|
+ (AFImageCache *)sharedImageCache;
|
||||||
|
|
||||||
- (UIImage *)cachedImageForRequest:(NSURLRequest *)urlRequest
|
- (UIImage *)cachedImageForRequest:(NSURLRequest *)urlRequest
|
||||||
cacheName:(NSString *)cacheName;
|
cacheName:(NSString *)cacheName;
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ static inline NSString * AFImageCacheKey(NSURLRequest *urlRequest, NSString *cac
|
||||||
|
|
||||||
@implementation AFImageCache
|
@implementation AFImageCache
|
||||||
|
|
||||||
+ (id)sharedImageCache {
|
+ (AFImageCache *)sharedImageCache {
|
||||||
static NSCache *_sharedImageCache = nil;
|
static AFImageCache *_sharedImageCache = nil;
|
||||||
static dispatch_once_t oncePredicate;
|
static dispatch_once_t oncePredicate;
|
||||||
|
|
||||||
dispatch_once(&oncePredicate, ^{
|
dispatch_once(&oncePredicate, ^{
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@
|
||||||
|
|
||||||
@interface AFImageRequestOperation : AFHTTPRequestOperation
|
@interface AFImageRequestOperation : AFHTTPRequestOperation
|
||||||
|
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
success:(void (^)(UIImage *image))success;
|
success:(void (^)(UIImage *image))success;
|
||||||
|
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
|
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
|
||||||
cacheName:(NSString *)cacheNameOrNil
|
cacheName:(NSString *)cacheNameOrNil
|
||||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
|
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@
|
||||||
#import "AFImageRequestOperation.h"
|
#import "AFImageRequestOperation.h"
|
||||||
#import "AFImageCache.h"
|
#import "AFImageCache.h"
|
||||||
|
|
||||||
#import "UIImage+AFNetworking.h"
|
|
||||||
|
|
||||||
static dispatch_queue_t af_image_request_operation_processing_queue;
|
static dispatch_queue_t af_image_request_operation_processing_queue;
|
||||||
static dispatch_queue_t image_request_operation_processing_queue() {
|
static dispatch_queue_t image_request_operation_processing_queue() {
|
||||||
if (af_image_request_operation_processing_queue == NULL) {
|
if (af_image_request_operation_processing_queue == NULL) {
|
||||||
|
|
@ -36,7 +34,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
|
||||||
|
|
||||||
@implementation AFImageRequestOperation
|
@implementation AFImageRequestOperation
|
||||||
|
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
success:(void (^)(UIImage *image))success
|
success:(void (^)(UIImage *image))success
|
||||||
{
|
{
|
||||||
return [self operationWithRequest:urlRequest imageProcessingBlock:nil cacheName:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
|
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];
|
} failure:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
|
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
|
||||||
cacheName:(NSString *)cacheNameOrNil
|
cacheName:(NSString *)cacheNameOrNil
|
||||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
|
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
|
||||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
|
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) {
|
dispatch_async(image_request_operation_processing_queue(), ^(void) {
|
||||||
if (error) {
|
if (error) {
|
||||||
if (failure) {
|
if (failure) {
|
||||||
|
|
@ -81,8 +79,6 @@ static dispatch_queue_t image_request_operation_processing_queue() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}];
|
}];
|
||||||
|
|
||||||
return operation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
@return A new JSON request operation
|
@return A new JSON request operation
|
||||||
*/
|
*/
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
success:(void (^)(id JSON))success;
|
success:(void (^)(id JSON))success;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
@return A new JSON request operation
|
@return A new JSON request operation
|
||||||
*/
|
*/
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
success:(void (^)(id JSON))success
|
success:(void (^)(id JSON))success
|
||||||
failure:(void (^)(NSError *error))failure;
|
failure:(void (^)(NSError *error))failure;
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
|
|
||||||
@return A new JSON request operation
|
@return A new JSON request operation
|
||||||
*/
|
*/
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
acceptableStatusCodes:(NSIndexSet *)acceptableStatusCodes
|
acceptableStatusCodes:(NSIndexSet *)acceptableStatusCodes
|
||||||
acceptableContentTypes:(NSSet *)acceptableContentTypes
|
acceptableContentTypes:(NSSet *)acceptableContentTypes
|
||||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
|
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,13 @@ static dispatch_queue_t json_request_operation_processing_queue() {
|
||||||
|
|
||||||
@implementation AFJSONRequestOperation
|
@implementation AFJSONRequestOperation
|
||||||
|
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
success:(void (^)(id JSON))success
|
success:(void (^)(id JSON))success
|
||||||
{
|
{
|
||||||
return [self operationWithRequest:urlRequest success:success failure:nil];
|
return [self operationWithRequest:urlRequest success:success failure:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
success:(void (^)(id JSON))success
|
success:(void (^)(id JSON))success
|
||||||
failure:(void (^)(NSError *error))failure
|
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
|
acceptableStatusCodes:(NSIndexSet *)acceptableStatusCodes
|
||||||
acceptableContentTypes:(NSSet *)acceptableContentTypes
|
acceptableContentTypes:(NSSet *)acceptableContentTypes
|
||||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
|
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
|
||||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
|
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 (!error) {
|
||||||
if (acceptableStatusCodes && ![acceptableStatusCodes containsIndex:[response statusCode]]) {
|
if (acceptableStatusCodes && ![acceptableStatusCodes containsIndex:[response statusCode]]) {
|
||||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||||
|
|
|
||||||
|
|
@ -27,5 +27,5 @@ extern NSString * const kAFGowallaClientID;
|
||||||
extern NSString * const kAFGowallaBaseURLString;
|
extern NSString * const kAFGowallaBaseURLString;
|
||||||
|
|
||||||
@interface AFGowallaAPIClient : AFRestClient
|
@interface AFGowallaAPIClient : AFRestClient
|
||||||
+ (id)sharedClient;
|
+ (AFGowallaAPIClient *)sharedClient;
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
#import "AFGowallaAPIClient.h"
|
#import "AFGowallaAPIClient.h"
|
||||||
|
|
||||||
static AFGowallaAPIClient *_sharedClient = nil;
|
|
||||||
|
|
||||||
// Replace this with your own API Key, available at http://api.gowalla.com/api/keys/
|
// Replace this with your own API Key, available at http://api.gowalla.com/api/keys/
|
||||||
NSString * const kAFGowallaClientID = @"e7ccb7d3d2414eb2af4663fc91eb2793";
|
NSString * const kAFGowallaClientID = @"e7ccb7d3d2414eb2af4663fc91eb2793";
|
||||||
|
|
||||||
|
|
@ -31,7 +29,8 @@ NSString * const kAFGowallaBaseURLString = @"https://api.gowalla.com/";
|
||||||
|
|
||||||
@implementation AFGowallaAPIClient
|
@implementation AFGowallaAPIClient
|
||||||
|
|
||||||
+ (id)sharedClient {
|
+ (AFGowallaAPIClient *)sharedClient {
|
||||||
|
static AFGowallaAPIClient *_sharedClient = nil;
|
||||||
static dispatch_once_t oncePredicate;
|
static dispatch_once_t oncePredicate;
|
||||||
dispatch_once(&oncePredicate, ^{
|
dispatch_once(&oncePredicate, ^{
|
||||||
_sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:kAFGowallaBaseURLString]];
|
_sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:kAFGowallaBaseURLString]];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue