From 1136bc5e2f8493cab0db582b336581c18d01e3dc Mon Sep 17 00:00:00 2001 From: Gareth du Plooy Date: Thu, 23 Aug 2012 11:59:54 -0500 Subject: [PATCH 1/2] Calling downloadProgress no longer casting [data length] to (long long) AFURLConnectionOperationProgressBlock specifies "bytes" as an NSInteger. Master was casting [data length] as a long long, resulting in compilation errors if attempting to compile with more strict complication rules. Only the totalBytes and totalBytesExpected are specified as (and correctly called with) long long values. --- AFNetworking/AFURLConnectionOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index ad462a4..e668aa2 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -563,7 +563,7 @@ didReceiveResponse:(NSURLResponse *)response if (self.downloadProgress) { dispatch_async(dispatch_get_main_queue(), ^{ - self.downloadProgress((long long)[data length], self.totalBytesRead, self.response.expectedContentLength); + self.downloadProgress([data length], self.totalBytesRead, self.response.expectedContentLength); }); } } From 13ec70cc8f5bc5acd3d579c60704e7a8638abc24 Mon Sep 17 00:00:00 2001 From: Gareth du Plooy Date: Thu, 23 Aug 2012 13:15:47 -0500 Subject: [PATCH 2/2] AFURLConnectionOperationProgressBlock bytes now NSUinteger This seems to be the most proper data type for this parameter. What gets passed in for uploadProgress is an NSInteger (guaranteed to be positive), and [NSData length], which is an NSUInteger, for downloadProgress. --- AFNetworking/AFURLConnectionOperation.h | 4 ++-- AFNetworking/AFURLConnectionOperation.m | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 4fa20ed..127747c 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -216,7 +216,7 @@ extern NSString * const AFNetworkingOperationDidFinishNotification; @see setDownloadProgressBlock */ -- (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block; +- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block; /** Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. @@ -225,7 +225,7 @@ extern NSString * const AFNetworkingOperationDidFinishNotification; @see setUploadProgressBlock */ -- (void)setDownloadProgressBlock:(void (^)(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block; +- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block; ///------------------------------------------------- /// @name Setting NSURLConnection Delegate Callbacks diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index e668aa2..98a0343 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -47,7 +47,7 @@ NSString * const AFNetworkingErrorDomain = @"com.alamofire.networking.error"; NSString * const AFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start"; NSString * const AFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish"; -typedef void (^AFURLConnectionOperationProgressBlock)(NSInteger bytes, long long totalBytes, long long totalBytesExpected); +typedef void (^AFURLConnectionOperationProgressBlock)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); typedef BOOL (^AFURLConnectionOperationAuthenticationAgainstProtectionSpaceBlock)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace); typedef void (^AFURLConnectionOperationAuthenticationChallengeBlock)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge); typedef NSCachedURLResponse * (^AFURLConnectionOperationCacheResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse); @@ -287,11 +287,11 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat } #endif -- (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block { +- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block { self.uploadProgress = block; } -- (void)setDownloadProgressBlock:(void (^)(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block { +- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block { self.downloadProgress = block; }