Merge branch 'fixes-for-strict-warnings' of https://github.com/ittybittyapps/AFNetworking into ittybittyapps-fixes-for-strict-warnings

Conflicts:
	AFNetworking/AFHTTPClient.m
	AFNetworking/AFHTTPRequestOperation.m
	AFNetworking/AFImageRequestOperation.h
	AFNetworking/AFNetworking.h
	AFNetworking/AFURLConnectionOperation.m
This commit is contained in:
Mattt Thompson 2012-11-30 15:09:11 -08:00
commit 0f35164082
11 changed files with 81 additions and 73 deletions

View file

@ -35,7 +35,7 @@
#import <netdb.h>
#endif
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
#import <UIKit/UIKit.h>
#endif
@ -148,14 +148,15 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) {
if([value isKindOfClass:[NSDictionary class]]) {
// 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:)];
[[[value allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]] enumerateObjectsUsingBlock:^(id nestedKey, NSUInteger idx, BOOL *stop) {
[[[value allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]] enumerateObjectsUsingBlock:^(id nestedKey, __unused NSUInteger idx, __unused BOOL *stop) {
id nestedValue = [value objectForKey:nestedKey];
if (nestedValue) {
[mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)];
}
}];
} else if([value isKindOfClass:[NSArray class]]) {
[value enumerateObjectsUsingBlock:^(id nestedValue, NSUInteger idx, BOOL *stop) {
NSArray *array = value;
[array enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) {
[mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)];
}];
} else {
@ -234,10 +235,10 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) {
NSString *preferredLanguageCodes = [[NSLocale preferredLanguages] componentsJoinedByString:@", "];
[self setDefaultHeader:@"Accept-Language" value:[NSString stringWithFormat:@"%@, en-us;q=0.8", preferredLanguageCodes]];
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
// User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
[self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0f)]];
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
[self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]];
#endif
@ -307,7 +308,7 @@ static const void * AFNetworkReachabilityRetainCallback(const void *info) {
return (__bridge_retained const void *)([(__bridge AFNetworkReachabilityStatusBlock)info copy]);
}
static void AFNetworkReachabilityReleaseCallback(const void *info) {}
static void AFNetworkReachabilityReleaseCallback(__unused const void *info) {}
- (void)startMonitoringNetworkReachability {
[self stopMonitoringNetworkReachability];
@ -578,7 +579,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {}
}
__block NSUInteger numberOfFinishedOperations = 0;
[operations enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[operations enumerateObjectsUsingBlock:^(id obj, __unused NSUInteger idx, __unused BOOL *stop) {
if ([(NSOperation *)obj isFinished]) {
numberOfFinishedOperations++;
}
@ -671,7 +672,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {}
- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:self.baseURL forKey:@"baseURL"];
[aCoder encodeInteger:self.stringEncoding forKey:@"stringEncoding"];
[aCoder encodeInteger:(NSInteger)self.stringEncoding forKey:@"stringEncoding"];
[aCoder encodeInteger:self.parameterEncoding forKey:@"parameterEncoding"];
[aCoder encodeObject:self.registeredHTTPOperationClassNames forKey:@"registeredHTTPOperationClassNames"];
[aCoder encodeObject:self.defaultHeaders forKey:@"defaultHeaders"];
@ -735,8 +736,8 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
@property (nonatomic, assign) BOOL hasInitialBoundary;
@property (nonatomic, assign) BOOL hasFinalBoundary;
@property (readonly, getter = hasBytesAvailable) BOOL bytesAvailable;
@property (readonly) unsigned long long contentLength;
@property (nonatomic, readonly, getter = hasBytesAvailable) BOOL bytesAvailable;
@property (nonatomic, readonly) unsigned long long contentLength;
- (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length;
@end
@ -744,8 +745,8 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
@interface AFMultipartBodyStream : NSInputStream <NSStreamDelegate>
@property (nonatomic, assign) NSUInteger numberOfBytesInPacket;
@property (nonatomic, assign) NSTimeInterval delay;
@property (readonly) unsigned long long contentLength;
@property (readonly, getter = isEmpty) BOOL empty;
@property (nonatomic, readonly) unsigned long long contentLength;
@property (nonatomic, readonly, getter = isEmpty) BOOL empty;
- (id)initWithStringEncoding:(NSStringEncoding)encoding;
- (void)setInitialAndFinalBoundaries;
@ -953,7 +954,7 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
break;
}
} else {
bytesRead += [self.currentHTTPBodyPart read:&buffer[bytesRead] maxLength:length - bytesRead];
bytesRead += [self.currentHTTPBodyPart read:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)];
if (self.delay > 0.0f) {
[NSThread sleepForTimeInterval:self.delay];
}
@ -963,7 +964,7 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
return bytesRead;
}
- (BOOL)getBuffer:(uint8_t **)buffer length:(NSUInteger *)len {
- (BOOL)getBuffer:(__unused uint8_t **)buffer length:(__unused NSUInteger *)len {
return NO;
}
@ -988,20 +989,20 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
self.streamStatus = NSStreamStatusClosed;
}
- (id)propertyForKey:(NSString *)key {
- (id)propertyForKey:(__unused NSString *)key {
return nil;
}
- (BOOL)setProperty:(id)property forKey:(NSString *)key {
- (BOOL)setProperty:(__unused id)property forKey:(__unused NSString *)key {
return NO;
}
- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop
forMode:(NSString *)mode
- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop
forMode:(__unused NSString *)mode
{}
- (void)removeFromRunLoop:(NSRunLoop *)aRunLoop
forMode:(NSString *)mode
- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop
forMode:(__unused NSString *)mode
{}
- (unsigned long long)contentLength {
@ -1015,17 +1016,17 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
#pragma mark - Undocumented CFReadStream Bridged Methods
- (void)_scheduleInCFRunLoop:(CFRunLoopRef)aRunLoop
forMode:(CFStringRef)aMode
- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop
forMode:(__unused CFStringRef)aMode
{}
- (void)_unscheduleFromCFRunLoop:(CFRunLoopRef)aRunLoop
forMode:(CFStringRef)aMode
- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop
forMode:(__unused CFStringRef)aMode
{}
- (BOOL)_setCFClientFlags:(CFOptionFlags)inFlags
callback:(CFReadStreamClientCallBack)inCallback
context:(CFStreamClientContext *)inContext {
- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags
callback:(__unused CFReadStreamClientCallBack)inCallback
context:(__unused CFStreamClientContext *)inContext {
return NO;
}
@ -1121,17 +1122,17 @@ typedef enum {
if (_phase == AFEncapsulationBoundaryPhase) {
NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding];
bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)];
bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)];
}
if (_phase == AFHeaderPhase) {
NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding];
bytesRead += [self readData:headersData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)];
bytesRead += [self readData:headersData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)];
}
if (_phase == AFBodyPhase) {
if ([self.inputStream hasBytesAvailable]) {
bytesRead += [self.inputStream read:&buffer[bytesRead] maxLength:(length - bytesRead)];
bytesRead += [self.inputStream read:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)];
}
if (![self.inputStream hasBytesAvailable]) {
@ -1141,7 +1142,7 @@ typedef enum {
if (_phase == AFFinalBoundaryPhase) {
NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding] : [NSData data]);
bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)];
bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)];
}
return bytesRead;
@ -1160,7 +1161,7 @@ typedef enum {
[self transitionToNextPhase];
}
return range.length;
return (NSInteger)range.length;
}
- (BOOL)transitionToNextPhase {
@ -1182,6 +1183,7 @@ typedef enum {
[self.inputStream close];
_phase = AFFinalBoundaryPhase;
break;
case AFFinalBoundaryPhase:
default:
_phase = AFEncapsulationBoundaryPhase;
break;

View file

@ -44,12 +44,12 @@
/**
A Boolean value that corresponds to whether the status code of the response is within the specified set of acceptable status codes. Returns `YES` if `acceptableStatusCodes` is `nil`.
*/
@property (readonly) BOOL hasAcceptableStatusCode;
@property (nonatomic, readonly) BOOL hasAcceptableStatusCode;
/**
A Boolean value that corresponds to whether the MIME type of the response is among the specified set of acceptable content types. Returns `YES` if `acceptableContentTypes` is `nil`.
*/
@property (readonly) BOOL hasAcceptableContentType;
@property (nonatomic, readonly) BOOL hasAcceptableContentType;
/**
The callback dispatch queue on success. If `NULL` (default), the main queue is used.

View file

@ -30,6 +30,10 @@
#define AF_CAST_TO_BLOCK __bridge void *
#endif
// We do a little bit of duck typing in this file which can trigger this warning. Turn it off for this source file.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wstrict-selector-match"
NSSet * AFContentTypesFromHTTPHeader(NSString *string) {
if (!string) {
return nil;
@ -38,7 +42,7 @@ NSSet * AFContentTypesFromHTTPHeader(NSString *string) {
NSArray *mediaRanges = [string componentsSeparatedByString:@","];
NSMutableSet *mutableContentTypes = [NSMutableSet setWithCapacity:mediaRanges.count];
[mediaRanges enumerateObjectsUsingBlock:^(NSString *mediaRange, NSUInteger idx, BOOL *stop) {
[mediaRanges enumerateObjectsUsingBlock:^(NSString *mediaRange, __unused NSUInteger idx, __unused BOOL *stop) {
NSRange parametersRange = [mediaRange rangeOfString:@";"];
if (parametersRange.location != NSNotFound) {
mediaRange = [mediaRange substringToIndex:parametersRange.location];
@ -105,8 +109,8 @@ static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL
@property (readwrite, nonatomic, strong) NSHTTPURLResponse *response;
@property (readwrite, nonatomic, strong) NSError *HTTPError;
@property (readwrite, nonatomic, copy) NSString *HTTPResponseString;
@property (assign) long long totalContentLength;
@property (assign) long long offsetContentLength;
@property (readwrite, nonatomic, assign) long long totalContentLength;
@property (readwrite, nonatomic, assign) long long offsetContentLength;
@end
@implementation AFHTTPRequestOperation
@ -299,7 +303,7 @@ static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL
+ (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes {
NSMutableIndexSet *mutableStatusCodes = [[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]];
[mutableStatusCodes addIndexes:statusCodes];
AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(id _self) {
AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(__unused id _self) {
return mutableStatusCodes;
});
}
@ -311,7 +315,7 @@ static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL
+ (void)addAcceptableContentTypes:(NSSet *)contentTypes {
NSMutableSet *mutableContentTypes = [[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES];
[mutableContentTypes unionSet:contentTypes];
AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(id _self) {
AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(__unused id _self) {
return mutableContentTypes;
});
}
@ -326,7 +330,7 @@ static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL
#pragma mark - NSURLConnectionDelegate
- (void)connection:(NSURLConnection *)connection
- (void)connection:(__unused NSURLConnection *)connection
didReceiveResponse:(NSURLResponse *)response
{
self.response = (NSHTTPURLResponse *)response;

View file

@ -25,9 +25,9 @@
#import <Availability.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
#import <UIKit/UIKit.h>
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
#import <Cocoa/Cocoa.h>
#endif
@ -54,13 +54,13 @@
/**
An image constructed from the response data. If an error occurs during the request, `nil` will be returned, and the `error` property will be set to the error.
*/
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
@property (readonly, nonatomic, strong) UIImage *responseImage;
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
@property (readonly, nonatomic, strong) NSImage *responseImage;
#endif
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
/**
The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance.
*/
@ -75,10 +75,10 @@
@return A new image request operation
*/
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(UIImage *image))success;
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(NSImage *image))success;
#endif
@ -93,12 +93,12 @@
@return A new image request operation
*/
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
imageProcessingBlock:(UIImage *(^)(UIImage *image))imageProcessingBlock
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
imageProcessingBlock:(NSImage *(^)(NSImage *image))imageProcessingBlock
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success

View file

@ -32,20 +32,20 @@ static dispatch_queue_t image_request_operation_processing_queue() {
}
@interface AFImageRequestOperation ()
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
@property (readwrite, nonatomic, strong) UIImage *responseImage;
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
@property (readwrite, nonatomic, strong) NSImage *responseImage;
#endif
@end
@implementation AFImageRequestOperation
@synthesize responseImage = _responseImage;
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
@synthesize imageScale = _imageScale;
#endif
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(UIImage *image))success
{
@ -55,7 +55,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
}
} failure:nil];
}
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(NSImage *image))success
{
@ -68,7 +68,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
#endif
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
@ -99,7 +99,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
return requestOperation;
}
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
imageProcessingBlock:(NSImage *(^)(NSImage *))imageProcessingBlock
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success
@ -137,7 +137,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
return nil;
}
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
self.imageScale = [[UIScreen mainScreen] scale];
#endif
@ -145,7 +145,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
}
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
- (UIImage *)responseImage {
if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) {
UIImage *image = [UIImage imageWithData:self.responseData];
@ -168,7 +168,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
self.responseImage = nil;
}
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
- (NSImage *)responseImage {
if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) {
// Ensure that the image is set to it's correct pixel width and height
@ -216,9 +216,9 @@ static dispatch_queue_t image_request_operation_processing_queue() {
}
} else {
if (success) {
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
UIImage *image = nil;
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
NSImage *image = nil;
#endif

View file

@ -24,7 +24,7 @@
#import <Availability.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
#import <UIKit/UIKit.h>
/**

View file

@ -24,7 +24,7 @@
#import "AFHTTPRequestOperation.h"
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17;
@interface AFNetworkActivityIndicatorManager ()

View file

@ -36,7 +36,7 @@
#import "AFImageRequestOperation.h"
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
#import "AFNetworkActivityIndicatorManager.h"
#import "UIImageView+AFNetworking.h"
#endif

View file

@ -189,7 +189,7 @@
@param handler A handler to be called shortly before the applications remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the applications suspension momentarily while the application is notified.
*/
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler;
#endif

View file

@ -22,7 +22,7 @@
#import "AFURLConnectionOperation.h"
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
#import <UIKit/UIKit.h>
#endif
@ -40,7 +40,7 @@ typedef enum {
typedef signed short AFOperationState;
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier;
#else
typedef id AFBackgroundTaskIdentifier;
@ -199,7 +199,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
_outputStream = nil;
}
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
if (_backgroundTaskIdentifier) {
[[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier];
_backgroundTaskIdentifier = UIBackgroundTaskInvalid;
@ -218,8 +218,10 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
} else {
__weak __typeof(&*self)weakSelf = self;
[super setCompletionBlock:^ {
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
block();
[weakSelf setCompletionBlock:nil];
[strongSelf setCompletionBlock:nil];
}];
}
[self.lock unlock];
@ -250,7 +252,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
[self didChangeValueForKey:@"outputStream"];
}
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler {
[self.lock lock];
if (!self.backgroundTaskIdentifier) {
@ -310,7 +312,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
_state = state;
[self didChangeValueForKey:oldStateKey];
[self didChangeValueForKey:newStateKey];
switch (state) {
case AFOperationExecutingState:
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self];
@ -539,7 +541,7 @@ totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
if (self.uploadProgress) {
dispatch_async(dispatch_get_main_queue(), ^{
self.uploadProgress(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
self.uploadProgress((NSUInteger)bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
});
}
}

View file

@ -23,7 +23,7 @@
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
#import "UIImageView+AFNetworking.h"
@interface AFImageCache : NSCache