From 7745e8f444ae3009598812f797355fe0a3acc0d2 Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Wed, 27 Mar 2013 15:06:47 +0100 Subject: [PATCH 01/10] Refactoring some loops to fast enumeration. --- AFNetworking/AFHTTPClient.m | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index bd0cab2..f349796 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -149,22 +149,22 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { NSDictionary *dictionary = value; // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(caseInsensitiveCompare:)]; - [[[dictionary allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]] enumerateObjectsUsingBlock:^(id nestedKey, __unused NSUInteger idx, __unused BOOL *stop) { - id nestedValue = [dictionary objectForKey:nestedKey]; + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + id nestedValue = dictionary[nestedKey]; if (nestedValue) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; } - }]; + } } else if ([value isKindOfClass:[NSArray class]]) { NSArray *array = value; - [array enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { + for (id nestedValue in array) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; - }]; + } } else if ([value isKindOfClass:[NSSet class]]) { NSSet *set = value; - [set enumerateObjectsUsingBlock:^(id obj, BOOL *stop) { + for (id obj in set) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; - }]; + } } else { [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; } @@ -605,12 +605,12 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) { originalCompletionBlock(); } - __block NSUInteger numberOfFinishedOperations = 0; - [operations enumerateObjectsUsingBlock:^(id obj, __unused NSUInteger idx, __unused BOOL *stop) { - if ([(NSOperation *)obj isFinished]) { + NSUInteger numberOfFinishedOperations = 0; + for (NSOperation *operation in operations) { + if (operation.isFinished) { numberOfFinishedOperations++; } - }]; + } if (progressBlock) { progressBlock(numberOfFinishedOperations, [operations count]); From c80bfef9e3134df3d5480c14531e38ce35fa2b2b Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 2 Apr 2013 11:24:38 -0700 Subject: [PATCH 02/10] Fix macro to work correctly under 10.7 SDK / iOS 4 SDK --- AFNetworking/AFURLConnectionOperation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index c50ce24..d240a7c 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -93,8 +93,8 @@ typedef enum { #endif @interface AFURLConnectionOperation : NSOperation = __IPHONE_5_0) || \ - (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8) +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_5_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && defined(__MAC_10_8) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8) NSURLConnectionDataDelegate, #endif NSCoding, NSCopying> From bc7544bb8aa77bed28623ffbdcf01a2e41724a13 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 2 Apr 2013 12:22:53 -0700 Subject: [PATCH 03/10] Use Apple's recommended style, and fix so it works under 10.7 or pre-5.0 --- AFNetworking/AFURLConnectionOperation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index d240a7c..8f8cd4e 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -93,8 +93,8 @@ typedef enum { #endif @interface AFURLConnectionOperation : NSOperation = __IPHONE_5_0) || \ - (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && defined(__MAC_10_8) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8) +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080) NSURLConnectionDataDelegate, #endif NSCoding, NSCopying> From bc149aa3c2f1b5b143b80012f7d0046eb42dafb8 Mon Sep 17 00:00:00 2001 From: Michele Date: Tue, 2 Apr 2013 17:13:30 -0700 Subject: [PATCH 04/10] Removed all @discussion tags, since they are not supported. --- AFNetworking/AFHTTPClient.h | 36 +++++++++---------- AFNetworking/AFHTTPRequestOperation.h | 4 +-- .../AFNetworkActivityIndicatorManager.h | 2 +- AFNetworking/AFURLConnectionOperation.h | 26 +++++++------- AFNetworking/UIImageView+AFNetworking.h | 10 +++--- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 5551f5d..ed7b208 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -160,11 +160,11 @@ typedef enum { /** Initializes an `AFHTTPClient` object with the specified base URL. + + This is the designated initializer. @param url The base URL for the HTTP client. This argument must not be `nil`. - @discussion This is the designated initializer. - @return The newly-initialized HTTP client */ - (id)initWithBaseURL:(NSURL *)url; @@ -191,11 +191,11 @@ typedef enum { /** Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request. + When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list. + @param operationClass The subclass of `AFHTTPRequestOperation` to register @return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`. - - @discussion When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list. */ - (BOOL)registerHTTPOperationClass:(Class)operationClass; @@ -283,13 +283,13 @@ typedef enum { /** Creates an `NSMutableURLRequest` object with the specified HTTP method and path, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 + Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and set in the request HTTP body. @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. This can be used to upload files, encode HTTP body as JSON or XML, or specify multiple values for the same parameter, as one might for array values. - @discussion Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. - @return An `NSMutableURLRequest` object */ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method @@ -327,11 +327,11 @@ typedef enum { /** Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path. + + This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property. @param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled. @param path The path appended to the HTTP client base URL to match against the cancelled requests. If `nil`, no path will be appended to the base URL. - - @discussion This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property. */ - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path; @@ -342,11 +342,11 @@ typedef enum { /** Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue for each specified request object into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes. + Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters. + @param urlRequests The `NSURLRequest` objects used to create and enqueue operations. @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations. @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations. - - @discussion Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters. */ - (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock @@ -506,13 +506,13 @@ typedef enum { /** Returns a query string constructed by a set of parameters, using the specified encoding. + Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&". + + If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component. + @param parameters The parameters used to construct the query string @param encoding The encoding to use in constructing the query string. If you are uncertain of the correct encoding, you should use UTF-8 (`NSUTF8StringEncoding`), which is the encoding designated by RFC 3986 as the correct encoding for use in URLs. - @discussion Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&". - - If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component. - @return A percent-escaped query string */ extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding); @@ -545,13 +545,13 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; /** Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. + The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. @param name The name to be associated with the specified data. This parameter must not be `nil`. @param error If an error occurs, upon return contains an `NSError` object that describes the problem. @return `YES` if the file data was successfully appended, otherwise `NO`. - - @discussion The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. */ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name @@ -625,10 +625,10 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; /** Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. + When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 32kb. @param delay Duration of delay each time a packet is read. By default, no delay is set. - - @discussion When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. */ - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes delay:(NSTimeInterval)delay; diff --git a/AFNetworking/AFHTTPRequestOperation.h b/AFNetworking/AFHTTPRequestOperation.h index 2ec99ac..b40e3d5 100644 --- a/AFNetworking/AFHTTPRequestOperation.h +++ b/AFNetworking/AFHTTPRequestOperation.h @@ -112,10 +112,10 @@ /** Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. + This method should be overridden in subclasses in order to specify the response object passed into the success block. + @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. - - @discussion This method should be overridden in subclasses in order to specify the response object passed into the success block. */ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.h b/AFNetworking/AFNetworkActivityIndicatorManager.h index bac7b5a..714193b 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.h +++ b/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -44,7 +44,7 @@ /** A Boolean value indicating whether the manager is enabled. - @discussion If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. + If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. */ @property (nonatomic, assign, getter = isEnabled) BOOL enabled; diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index c50ce24..50913ce 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -144,7 +144,7 @@ NSCoding, NSCopying> /** The string encoding of the response. - @discussion If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. + If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. */ @property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; @@ -155,21 +155,21 @@ NSCoding, NSCopying> /** Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. - @discussion This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. + This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. */ @property (nonatomic, assign) BOOL shouldUseCredentialStorage; /** The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. - @discussion This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. + This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. */ @property (nonatomic, strong) NSURLCredential *credential; /** The pinning mode which will be used for SSL connections. `AFSSLPinningModePublicKey` by default. - @discussion To enable SSL Pinning, `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` in `Prefix.pch`. Also, make sure that the Security framework is linked with the binary. See the "SSL Pinning" section in the `AFURLConnectionOperation`" header for more information. + To enable SSL Pinning, `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` in `Prefix.pch`. Also, make sure that the Security framework is linked with the binary. See the "SSL Pinning" section in the `AFURLConnectionOperation`" header for more information. */ #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ @property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode SSLPinningMode; @@ -182,14 +182,14 @@ NSCoding, NSCopying> /** The input stream used to read data to be sent during the request. - @discussion This property acts as a proxy to the `HTTPBodyStream` property of `request`. + This property acts as a proxy to the `HTTPBodyStream` property of `request`. */ @property (nonatomic, strong) NSInputStream *inputStream; /** The output stream that is used to write data received until the request is finished. - @discussion By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. + By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. */ @property (nonatomic, strong) NSOutputStream *outputStream; @@ -208,10 +208,10 @@ NSCoding, NSCopying> /** Initializes and returns a newly allocated operation object with a url connection configured with the specified url request. - + + This is the designated initializer. + @param urlRequest The request object to be used by the operation connection. - - @discussion This is the designated initializer. */ - (id)initWithRequest:(NSURLRequest *)urlRequest; @@ -222,7 +222,7 @@ NSCoding, NSCopying> /** Pauses the execution of the request operation. - @discussion A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. + A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. */ - (void)pause; @@ -236,7 +236,7 @@ NSCoding, NSCopying> /** Resumes the execution of the paused request operation. - @discussion Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. + Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. */ - (void)resume; @@ -280,7 +280,7 @@ NSCoding, NSCopying> @param block A block object to be executed to determine whether the connection should be able to respond to a protection space's form of authentication. The block has a `BOOL` return type and takes two arguments: the URL connection object, and the protection space to authenticate against. - @discussion If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. + If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. */ - (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace))block; @@ -289,7 +289,7 @@ NSCoding, NSCopying> @param block A block object to be executed when the connection must authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. - @discussion If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. + If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. */ - (void)setAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; diff --git a/AFNetworking/UIImageView+AFNetworking.h b/AFNetworking/UIImageView+AFNetworking.h index f9a389f..bafb790 100644 --- a/AFNetworking/UIImageView+AFNetworking.h +++ b/AFNetworking/UIImageView+AFNetworking.h @@ -36,7 +36,7 @@ /** Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL, and sets it the request is finished. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - @discussion By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` @param url The URL used for the image request. */ @@ -45,23 +45,23 @@ /** Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + @param url The URL used for the image request. @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. - - @discussion By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` */ - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage; /** Creates and enqueues an image request operation, which asynchronously downloads the image with the specified URL request object. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is executed. @param urlRequest The URL request used for the image request. @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. @param success A block to be executed when the image request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the request and response parameters will be `nil`. @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. - - @discussion If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is executed. */ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest placeholderImage:(UIImage *)placeholderImage From ab00b9559caabecb4c0b855dfe45fc4b727299e9 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Sat, 6 Apr 2013 12:11:29 +0200 Subject: [PATCH 05/10] Fixing AFImageRequestOperation to use [self alloc] instead of explicit class in class method in order to preserve behavior in subclasses Signed-off-by: Mattt Thompson --- AFNetworking/AFImageRequestOperation.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index 0a0390f..cfac8d9 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -75,7 +75,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure { - AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest]; + AFImageRequestOperation *requestOperation = [(AFImageRequestOperation *)[self alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if (success) { UIImage *image = responseObject; @@ -106,7 +106,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure { - AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest]; + AFImageRequestOperation *requestOperation = [(AFImageRequestOperation *)[self alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if (success) { NSImage *image = responseObject; From bab6a8b28f947731f95280e4f5a0101cf0b7a95b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 6 Apr 2013 12:42:01 +0200 Subject: [PATCH 06/10] Set AFNetworking thread name Signed-off-by: Mattt Thompson --- AFNetworking/AFURLConnectionOperation.m | 1 + 1 file changed, 1 insertion(+) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 51cfd6b..0d9bac7 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -162,6 +162,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat + (void) __attribute__((noreturn)) networkRequestThreadEntryPoint:(id)__unused object { do { @autoreleasepool { + [[NSThread currentThread] setName:@"AFNetworking"]; [[NSRunLoop currentRunLoop] run]; } } while (YES); From 205a8aa7e3da2cece0491f41dfb89b3cb267ee11 Mon Sep 17 00:00:00 2001 From: Sebastian Utz Date: Sat, 6 Apr 2013 15:42:10 +0200 Subject: [PATCH 07/10] Only encode JSON with UTF8, following recommendation of NSJSONSerialization documentation Signed-off-by: Mattt Thompson --- AFNetworking/AFJSONRequestOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 008aacc..ac7423a 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -75,7 +75,7 @@ static dispatch_queue_t json_request_operation_processing_queue() { } else { // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character // See http://stackoverflow.com/a/12843465/157142 - NSData *JSONData = [self.responseString dataUsingEncoding:self.responseStringEncoding]; + NSData *JSONData = [self.responseString dataUsingEncoding:NSUTF8StringEncoding]; self.responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:self.JSONReadingOptions error:&error]; } From 7207f2f19f6f93a549432e1b5316bccc74cee2d8 Mon Sep 17 00:00:00 2001 From: "@scutdavy" Date: Sat, 6 Apr 2013 20:06:15 +0200 Subject: [PATCH 08/10] Using indexesOfObjectsPassingTest to calculate numberOfFinishedOperations in -enqueueBatchOfHTTPRequestOperations: Signed-off-by: Mattt Thompson --- AFNetworking/AFHTTPClient.m | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f349796..47a0119 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -605,12 +605,9 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) { originalCompletionBlock(); } - NSUInteger numberOfFinishedOperations = 0; - for (NSOperation *operation in operations) { - if (operation.isFinished) { - numberOfFinishedOperations++; - } - } + NSInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger idx, BOOL *stop) { + return [op isCancelled]; + }] count]; if (progressBlock) { progressBlock(numberOfFinishedOperations, [operations count]); From 48398eb0acae85299159598bcae6501a43c1338b Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 6 Apr 2013 20:09:23 +0200 Subject: [PATCH 09/10] Adding __unused to block paramters --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 47a0119..1d8c663 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -605,7 +605,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) { originalCompletionBlock(); } - NSInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger idx, BOOL *stop) { + NSInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger __unused idx, BOOL __unused *stop) { return [op isCancelled]; }] count]; From 6d64ea1fa50f09f495bed1791d65fbd8e7c1a614 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 6 Apr 2013 20:17:35 +0200 Subject: [PATCH 10/10] [Issue #888] Fixing property attribution build warning in AFHTTPClient body stream provider --- AFNetworking/AFHTTPClient.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 1d8c663..f38c307 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -761,7 +761,7 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; @property (nonatomic, strong) NSDictionary *headers; @property (nonatomic, strong) id body; @property (nonatomic, assign) unsigned long long bodyContentLength; -@property (nonatomic, readonly) NSInputStream *inputStream; +@property (nonatomic, strong) NSInputStream *inputStream; @property (nonatomic, assign) BOOL hasInitialBoundary; @property (nonatomic, assign) BOOL hasFinalBoundary; @@ -776,7 +776,7 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; @interface AFMultipartBodyStreamProvider : NSObject @property (nonatomic, assign) NSUInteger bufferLength; @property (nonatomic, assign) NSTimeInterval delay; -@property (nonatomic, readonly) NSInputStream *inputStream; +@property (nonatomic, strong) NSInputStream *inputStream; @property (nonatomic, readonly) unsigned long long contentLength; @property (nonatomic, readonly, getter = isEmpty) BOOL empty; @@ -968,7 +968,6 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; @property (nonatomic, strong) NSMutableArray *HTTPBodyParts; @property (nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; @property (nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; -@property (nonatomic, strong) NSInputStream *inputStream; @property (nonatomic, strong) NSOutputStream *outputStream; @property (nonatomic, strong) NSMutableData *buffer; @end