Skip to content

Commit db4c852

Browse files
committed
[Issue domesticcatsoftware#33] Changing return type of class method object contructors from id to an actual instance of that class
1 parent f422caf commit db4c852

10 files changed

Lines changed: 54 additions & 59 deletions

AFNetworking/AFHTTPRequestOperation.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ extern NSString * const AFHTTPOperationDidFinishNotification;
8282
8383
@return A new HTTP request operation
8484
*/
85-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
86-
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion;
85+
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
86+
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion;
8787

8888
/**
8989
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;
9797
9898
@return A new HTTP request operation
9999
*/
100-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
101-
inputStream:(NSInputStream *)inputStream
102-
outputStream:(NSOutputStream *)outputStream
103-
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion;
100+
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
101+
inputStream:(NSInputStream *)inputStream
102+
outputStream:(NSOutputStream *)outputStream
103+
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion;
104104

105105
///---------------------------------
106106
/// @name Setting Progress Callbacks

AFNetworking/AFHTTPRequestOperation.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ + (NSThread *)networkRequestThread {
134134
return _networkRequestThread;
135135
}
136136

137-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
137+
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
138138
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion
139139
{
140140
AFHTTPRequestOperation *operation = [[[self alloc] initWithRequest:urlRequest] autorelease];
@@ -143,10 +143,10 @@ + (id)operationWithRequest:(NSURLRequest *)urlRequest
143143
return operation;
144144
}
145145

146-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
147-
inputStream:(NSInputStream *)inputStream
148-
outputStream:(NSOutputStream *)outputStream
149-
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion
146+
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
147+
inputStream:(NSInputStream *)inputStream
148+
outputStream:(NSOutputStream *)outputStream
149+
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))completion
150150
{
151151
NSMutableURLRequest *mutableURLRequest = [[urlRequest mutableCopy] autorelease];
152152
if (inputStream) {
@@ -175,7 +175,7 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest {
175175

176176
self.request = urlRequest;
177177

178-
self.runLoopModes = [NSSet setWithObjects:NSRunLoopCommonModes, nil];
178+
self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes];
179179

180180
self.state = AFHTTPOperationReadyState;
181181

AFNetworking/AFImageCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
@interface AFImageCache : NSCache
2727

28-
+ (id)sharedImageCache;
28+
+ (AFImageCache *)sharedImageCache;
2929

3030
- (UIImage *)cachedImageForRequest:(NSURLRequest *)urlRequest
3131
cacheName:(NSString *)cacheName;

AFNetworking/AFImageCache.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
@implementation AFImageCache
3030

31-
+ (id)sharedImageCache {
32-
static NSCache *_sharedImageCache = nil;
31+
+ (AFImageCache *)sharedImageCache {
32+
static AFImageCache *_sharedImageCache = nil;
3333
static dispatch_once_t oncePredicate;
3434

3535
dispatch_once(&oncePredicate, ^{

AFNetworking/AFImageRequestOperation.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626

2727
@interface AFImageRequestOperation : AFHTTPRequestOperation
2828

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

32-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
33-
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
34-
cacheName:(NSString *)cacheNameOrNil
35-
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
36-
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
32+
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
33+
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
34+
cacheName:(NSString *)cacheNameOrNil
35+
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
36+
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
3737

3838
@end

AFNetworking/AFImageRequestOperation.m

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#import "AFImageRequestOperation.h"
2424
#import "AFImageCache.h"
2525

26-
#import "UIImage+AFNetworking.h"
27-
2826
static dispatch_queue_t af_image_request_operation_processing_queue;
2927
static dispatch_queue_t image_request_operation_processing_queue() {
3028
if (af_image_request_operation_processing_queue == NULL) {
@@ -36,8 +34,8 @@ static dispatch_queue_t image_request_operation_processing_queue() {
3634

3735
@implementation AFImageRequestOperation
3836

39-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
40-
success:(void (^)(UIImage *image))success
37+
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
38+
success:(void (^)(UIImage *image))success
4139
{
4240
return [self operationWithRequest:urlRequest imageProcessingBlock:nil cacheName:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
4341
if (success) {
@@ -46,13 +44,13 @@ + (id)operationWithRequest:(NSURLRequest *)urlRequest
4644
} failure:nil];
4745
}
4846

49-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
50-
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
51-
cacheName:(NSString *)cacheNameOrNil
52-
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
53-
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
47+
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
48+
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
49+
cacheName:(NSString *)cacheNameOrNil
50+
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
51+
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
5452
{
55-
AFImageRequestOperation *operation = [self operationWithRequest:urlRequest completion:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error) {
53+
return (AFImageRequestOperation *)[self operationWithRequest:urlRequest completion:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error) {
5654
dispatch_async(image_request_operation_processing_queue(), ^(void) {
5755
if (error) {
5856
if (failure) {
@@ -81,8 +79,6 @@ + (id)operationWithRequest:(NSURLRequest *)urlRequest
8179
}
8280
});
8381
}];
84-
85-
return operation;
8682
}
8783

8884
@end

AFNetworking/AFJSONRequestOperation.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
4141
@return A new JSON request operation
4242
*/
43-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
44-
success:(void (^)(id JSON))success;
43+
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
44+
success:(void (^)(id JSON))success;
4545

4646
/**
4747
Creates and returns an `AFJSONRequestOperation` object and sets the specified success and failure callbacks.
@@ -56,9 +56,9 @@
5656
5757
@return A new JSON request operation
5858
*/
59-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
60-
success:(void (^)(id JSON))success
61-
failure:(void (^)(NSError *error))failure;
59+
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
60+
success:(void (^)(id JSON))success
61+
failure:(void (^)(NSError *error))failure;
6262

6363
/**
6464
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 @@
7171
7272
@return A new JSON request operation
7373
*/
74-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
75-
acceptableStatusCodes:(NSIndexSet *)acceptableStatusCodes
76-
acceptableContentTypes:(NSSet *)acceptableContentTypes
77-
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
78-
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
74+
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
75+
acceptableStatusCodes:(NSIndexSet *)acceptableStatusCodes
76+
acceptableContentTypes:(NSSet *)acceptableContentTypes
77+
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
78+
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
7979

8080

8181
///----------------------------------

AFNetworking/AFJSONRequestOperation.m

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ static dispatch_queue_t json_request_operation_processing_queue() {
3636

3737
@implementation AFJSONRequestOperation
3838

39-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
40-
success:(void (^)(id JSON))success
39+
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
40+
success:(void (^)(id JSON))success
4141
{
4242
return [self operationWithRequest:urlRequest success:success failure:nil];
4343
}
4444

45-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
46-
success:(void (^)(id JSON))success
47-
failure:(void (^)(NSError *error))failure
45+
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
46+
success:(void (^)(id JSON))success
47+
failure:(void (^)(NSError *error))failure
4848
{
4949
return [self operationWithRequest:urlRequest acceptableStatusCodes:[self defaultAcceptableStatusCodes] acceptableContentTypes:[self defaultAcceptableContentTypes] success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
5050
if (success) {
@@ -57,13 +57,13 @@ + (id)operationWithRequest:(NSURLRequest *)urlRequest
5757
}];
5858
}
5959

60-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
61-
acceptableStatusCodes:(NSIndexSet *)acceptableStatusCodes
62-
acceptableContentTypes:(NSSet *)acceptableContentTypes
63-
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
64-
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
60+
+ (AFJSONRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
61+
acceptableStatusCodes:(NSIndexSet *)acceptableStatusCodes
62+
acceptableContentTypes:(NSSet *)acceptableContentTypes
63+
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
64+
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
6565
{
66-
return [self operationWithRequest:urlRequest completion:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error) {
66+
return (AFJSONRequestOperation *)[self operationWithRequest:urlRequest completion:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error) {
6767
if (!error) {
6868
if (acceptableStatusCodes && ![acceptableStatusCodes containsIndex:[response statusCode]]) {
6969
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];

Example/Classes/AFGowallaAPIClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ extern NSString * const kAFGowallaClientID;
2727
extern NSString * const kAFGowallaBaseURLString;
2828

2929
@interface AFGowallaAPIClient : AFRestClient
30-
+ (id)sharedClient;
30+
+ (AFGowallaAPIClient *)sharedClient;
3131
@end

Example/Classes/AFGowallaAPIClient.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@
2222

2323
#import "AFGowallaAPIClient.h"
2424

25-
static AFGowallaAPIClient *_sharedClient = nil;
26-
2725
// Replace this with your own API Key, available at http://api.gowalla.com/api/keys/
2826
NSString * const kAFGowallaClientID = @"e7ccb7d3d2414eb2af4663fc91eb2793";
2927

3028
NSString * const kAFGowallaBaseURLString = @"https://api.gowalla.com/";
3129

3230
@implementation AFGowallaAPIClient
3331

34-
+ (id)sharedClient {
32+
+ (AFGowallaAPIClient *)sharedClient {
33+
static AFGowallaAPIClient *_sharedClient = nil;
3534
static dispatch_once_t oncePredicate;
3635
dispatch_once(&oncePredicate, ^{
3736
_sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:kAFGowallaBaseURLString]];

0 commit comments

Comments
 (0)