Merge branch '1.0RC2'

This commit is contained in:
Mattt Thompson 2012-09-14 10:59:18 -07:00
commit c8380168f8
33 changed files with 241 additions and 579 deletions

View file

@ -1,11 +1,11 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'AFNetworking' s.name = 'AFNetworking'
s.version = '0.10.1' s.version = '1.0RC2'
s.license = 'MIT' s.license = 'MIT'
s.summary = 'A delightful iOS and OS X networking framework.' s.summary = 'A delightful iOS and OS X networking framework.'
s.homepage = 'https://github.com/AFNetworking/AFNetworking' s.homepage = 'https://github.com/AFNetworking/AFNetworking'
s.authors = {'Mattt Thompson' => 'm@mattt.me', 'Scott Raymond' => 'sco@scottraymond.net'} s.authors = {'Mattt Thompson' => 'm@mattt.me', 'Scott Raymond' => 'sco@scottraymond.net'}
s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => '0.10.1' } s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => '1.0RC2' }
s.source_files = 'AFNetworking' s.source_files = 'AFNetworking'
s.framework = 'SystemConfiguration' s.framework = 'SystemConfiguration'
s.prefix_header_contents = "#import <SystemConfiguration/SystemConfiguration.h>" s.prefix_header_contents = "#import <SystemConfiguration/SystemConfiguration.h>"

View file

@ -99,7 +99,7 @@ typedef enum {
/** /**
The url used as the base for paths specified in methods such as `getPath:parameters:success:failure` The url used as the base for paths specified in methods such as `getPath:parameters:success:failure`
*/ */
@property (readonly, nonatomic, retain) NSURL *baseURL; @property (readonly, nonatomic) NSURL *baseURL;
/** /**
The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default. The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default.
@ -116,7 +116,7 @@ typedef enum {
/** /**
The operation queue which manages operations enqueued by the HTTP client. The operation queue which manages operations enqueued by the HTTP client.
*/ */
@property (readonly, nonatomic, retain) NSOperationQueue *operationQueue; @property (readonly, nonatomic) NSOperationQueue *operationQueue;
/** /**
The reachability status from the device to the current `baseURL` of the `AFHTTPClient`. The reachability status from the device to the current `baseURL` of the `AFHTTPClient`.

View file

@ -24,7 +24,6 @@
#import "AFHTTPClient.h" #import "AFHTTPClient.h"
#import "AFHTTPRequestOperation.h" #import "AFHTTPRequestOperation.h"
#import "AFJSONUtilities.h"
#import <Availability.h> #import <Availability.h>
@ -90,14 +89,14 @@ static NSString * AFBase64EncodedStringFromString(NSString *string) {
output[idx + 3] = (i + 2) < length ? kAFBase64EncodingTable[(value >> 0) & 0x3F] : '='; output[idx + 3] = (i + 2) < length ? kAFBase64EncodingTable[(value >> 0) & 0x3F] : '=';
} }
return [[[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding] autorelease]; return [[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding];
} }
static NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { static NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) {
// Escape characters that are legal in URIs, but have unintentional semantic significance when used in a query string parameter // Escape characters that are legal in URIs, but have unintentional semantic significance when used in a query string parameter
static NSString * const kAFLegalCharactersToBeEscaped = @":/.?&=;+!@$()~"; static NSString * const kAFLegalCharactersToBeEscaped = @":/.?&=;+!@$()~";
return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, (CFStringRef)kAFLegalCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)) autorelease]; return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, NULL, (__bridge CFStringRef)kAFLegalCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding));
} }
#pragma mark - #pragma mark -
@ -127,12 +126,6 @@ static NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NS
return self; return self;
} }
- (void)dealloc {
[_field release];
[_value release];
[super dealloc];
}
- (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding { - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding {
return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(self.field, stringEncoding), AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.value description], stringEncoding)]; return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(self.field, stringEncoding), AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.value description], stringEncoding)];
} }
@ -169,7 +162,7 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) {
[mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)];
}]; }];
} else { } else {
[mutableQueryStringComponents addObject:[[[AFQueryStringPair alloc] initWithField:key value:value] autorelease]]; [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]];
} }
return mutableQueryStringComponents; return mutableQueryStringComponents;
@ -177,10 +170,10 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) {
static NSString * AFJSONStringFromParameters(NSDictionary *parameters) { static NSString * AFJSONStringFromParameters(NSDictionary *parameters) {
NSError *error = nil; NSError *error = nil;
NSData *JSONData = AFJSONEncode(parameters, &error); NSData *JSONData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error];;
if (!error) { if (!error) {
return [[[NSString alloc] initWithData:JSONData encoding:NSUTF8StringEncoding] autorelease]; return [[NSString alloc] initWithData:JSONData encoding:NSUTF8StringEncoding];
} else { } else {
return nil; return nil;
} }
@ -192,17 +185,17 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
NSData *propertyListData = [NSPropertyListSerialization dataWithPropertyList:parameters format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; NSData *propertyListData = [NSPropertyListSerialization dataWithPropertyList:parameters format:NSPropertyListXMLFormat_v1_0 options:0 error:&error];
if (!error) { if (!error) {
propertyListString = [[[NSString alloc] initWithData:propertyListData encoding:NSUTF8StringEncoding] autorelease]; propertyListString = [[NSString alloc] initWithData:propertyListData encoding:NSUTF8StringEncoding] ;
} }
return propertyListString; return propertyListString;
} }
@interface AFHTTPClient () @interface AFHTTPClient ()
@property (readwrite, nonatomic, retain) NSURL *baseURL; @property (readwrite, nonatomic) NSURL *baseURL;
@property (readwrite, nonatomic, retain) NSMutableArray *registeredHTTPOperationClassNames; @property (readwrite, nonatomic) NSMutableArray *registeredHTTPOperationClassNames;
@property (readwrite, nonatomic, retain) NSMutableDictionary *defaultHeaders; @property (readwrite, nonatomic) NSMutableDictionary *defaultHeaders;
@property (readwrite, nonatomic, retain) NSOperationQueue *operationQueue; @property (readwrite, nonatomic) NSOperationQueue *operationQueue;
#ifdef _SYSTEMCONFIGURATION_H #ifdef _SYSTEMCONFIGURATION_H
@property (readwrite, nonatomic, assign) AFNetworkReachabilityRef networkReachability; @property (readwrite, nonatomic, assign) AFNetworkReachabilityRef networkReachability;
@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
@ -229,7 +222,7 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
#endif #endif
+ (AFHTTPClient *)clientWithBaseURL:(NSURL *)url { + (AFHTTPClient *)clientWithBaseURL:(NSURL *)url {
return [[[self alloc] initWithBaseURL:url] autorelease]; return [[self alloc] initWithBaseURL:url];
} }
- (id)initWithBaseURL:(NSURL *)url { - (id)initWithBaseURL:(NSURL *)url {
@ -258,7 +251,7 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
#if __IPHONE_OS_VERSION_MIN_REQUIRED #if __IPHONE_OS_VERSION_MIN_REQUIRED
// User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 // 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], 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)]]; [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 __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]]]; [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 #endif
@ -268,7 +261,7 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
[self startMonitoringNetworkReachability]; [self startMonitoringNetworkReachability];
#endif #endif
self.operationQueue = [[[NSOperationQueue alloc] init] autorelease]; self.operationQueue = [[NSOperationQueue alloc] init];
[self.operationQueue setMaxConcurrentOperationCount:NSOperationQueueDefaultMaxConcurrentOperationCount]; [self.operationQueue setMaxConcurrentOperationCount:NSOperationQueueDefaultMaxConcurrentOperationCount];
return self; return self;
@ -277,15 +270,7 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
- (void)dealloc { - (void)dealloc {
#ifdef _SYSTEMCONFIGURATION_H #ifdef _SYSTEMCONFIGURATION_H
[self stopMonitoringNetworkReachability]; [self stopMonitoringNetworkReachability];
[_networkReachabilityStatusBlock release];
#endif #endif
[_baseURL release];
[_registeredHTTPOperationClassNames release];
[_defaultHeaders release];
[_operationQueue release];
[super dealloc];
} }
- (NSString *)description { - (NSString *)description {
@ -325,7 +310,7 @@ static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetwork
static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
AFNetworkReachabilityStatusBlock block = (AFNetworkReachabilityStatusBlock)info; AFNetworkReachabilityStatusBlock block = (__bridge AFNetworkReachabilityStatusBlock)info;
if (block) { if (block) {
block(status); block(status);
} }
@ -334,11 +319,10 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ
} }
static const void * AFNetworkReachabilityRetainCallback(const void *info) { static const void * AFNetworkReachabilityRetainCallback(const void *info) {
return [(AFNetworkReachabilityStatusBlock)info copy]; return (__bridge_retained const void *)([(__bridge AFNetworkReachabilityStatusBlock)info copy]);
} }
static void AFNetworkReachabilityReleaseCallback(const void *info) { static void AFNetworkReachabilityReleaseCallback(const void *info) {
[(AFNetworkReachabilityStatusBlock)info release];
} }
- (void)startMonitoringNetworkReachability { - (void)startMonitoringNetworkReachability {
@ -357,7 +341,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
} }
}; };
SCNetworkReachabilityContext context = {0, callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context);
SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes); SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes);
@ -434,9 +418,10 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters
{ {
NSURL *url = [NSURL URLWithString:path relativeToURL:self.baseURL]; NSURL *url = [NSURL URLWithString:path relativeToURL:self.baseURL];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
[request setHTTPMethod:method]; [request setHTTPMethod:method];
[request setAllHTTPHeaderFields:self.defaultHeaders]; [request setAllHTTPHeaderFields:self.defaultHeaders];
[request setHTTPShouldHandleCookies:NO];
if ([method isEqualToString:@"GET"] || [method isEqualToString:@"HEAD"]) { if ([method isEqualToString:@"GET"] || [method isEqualToString:@"HEAD"]) {
[request setHTTPShouldUsePipelining:YES]; [request setHTTPShouldUsePipelining:YES];
@ -447,7 +432,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding)]]; url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding)]];
[request setURL:url]; [request setURL:url];
} else { } else {
NSString *charset = (NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding)); NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding));
switch (self.parameterEncoding) { switch (self.parameterEncoding) {
case AFFormURLParameterEncoding:; case AFFormURLParameterEncoding:;
[request setValue:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@", charset] forHTTPHeaderField:@"Content-Type"]; [request setValue:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@", charset] forHTTPHeaderField:@"Content-Type"];
@ -474,7 +459,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
constructingBodyWithBlock:(void (^)(id <AFMultipartFormData>formData))block constructingBodyWithBlock:(void (^)(id <AFMultipartFormData>formData))block
{ {
NSMutableURLRequest *request = [self requestWithMethod:method path:path parameters:nil]; NSMutableURLRequest *request = [self requestWithMethod:method path:path parameters:nil];
__block AFMultipartFormData *formData = [[[AFMultipartFormData alloc] initWithURLRequest:request stringEncoding:self.stringEncoding] autorelease]; __block AFMultipartFormData *formData = [[AFMultipartFormData alloc] initWithURLRequest:request stringEncoding:self.stringEncoding];
if (parameters) { if (parameters) {
for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) {
@ -508,12 +493,12 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
while (!operation && (className = [enumerator nextObject])) { while (!operation && (className = [enumerator nextObject])) {
Class op_class = NSClassFromString(className); Class op_class = NSClassFromString(className);
if (op_class && [op_class canProcessRequest:urlRequest]) { if (op_class && [op_class canProcessRequest:urlRequest]) {
operation = [[(AFHTTPRequestOperation *)[op_class alloc] initWithRequest:urlRequest] autorelease]; operation = [(AFHTTPRequestOperation *)[op_class alloc] initWithRequest:urlRequest];
} }
} }
if (!operation) { if (!operation) {
operation = [[[AFHTTPRequestOperation alloc] initWithRequest:urlRequest] autorelease]; operation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
} }
[operation setCompletionBlockWithSuccess:success failure:failure]; [operation setCompletionBlockWithSuccess:success failure:failure];
@ -567,9 +552,9 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
}]; }];
for (AFHTTPRequestOperation *operation in operations) { for (AFHTTPRequestOperation *operation in operations) {
AFCompletionBlock originalCompletionBlock = [[operation.completionBlock copy] autorelease]; AFCompletionBlock originalCompletionBlock = [operation.completionBlock copy];
operation.completionBlock = ^{ operation.completionBlock = ^{
dispatch_queue_t queue = operation.successCallbackQueue ? operation.successCallbackQueue : dispatch_get_main_queue(); dispatch_queue_t queue = operation.successCallbackQueue ?: dispatch_get_main_queue();
dispatch_group_async(dispatchGroup, queue, ^{ dispatch_group_async(dispatchGroup, queue, ^{
if (originalCompletionBlock) { if (originalCompletionBlock) {
originalCompletionBlock(); originalCompletionBlock();
@ -683,8 +668,8 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
HTTPClient.stringEncoding = self.stringEncoding; HTTPClient.stringEncoding = self.stringEncoding;
HTTPClient.parameterEncoding = self.parameterEncoding; HTTPClient.parameterEncoding = self.parameterEncoding;
HTTPClient.registeredHTTPOperationClassNames = [[self.registeredHTTPOperationClassNames copyWithZone:zone] autorelease]; HTTPClient.registeredHTTPOperationClassNames = [self.registeredHTTPOperationClassNames copyWithZone:zone];
HTTPClient.defaultHeaders = [[self.defaultHeaders copyWithZone:zone] autorelease]; HTTPClient.defaultHeaders = [self.defaultHeaders copyWithZone:zone];
#ifdef _SYSTEMCONFIGURATION_H #ifdef _SYSTEMCONFIGURATION_H
HTTPClient.networkReachabilityStatusBlock = self.networkReachabilityStatusBlock; HTTPClient.networkReachabilityStatusBlock = self.networkReachabilityStatusBlock;
#endif #endif
@ -729,9 +714,9 @@ static inline NSString * AFMultipartFormFinalBoundary() {
} }
@interface AFMultipartFormData () @interface AFMultipartFormData ()
@property (readwrite, nonatomic, retain) NSMutableURLRequest *request; @property (readwrite, nonatomic) NSMutableURLRequest *request;
@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; @property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding;
@property (readwrite, nonatomic, retain) NSOutputStream *outputStream; @property (readwrite, nonatomic, strong) NSOutputStream *outputStream;
@property (readwrite, nonatomic, copy) NSString *temporaryFilePath; @property (readwrite, nonatomic, copy) NSString *temporaryFilePath;
@end @end
@ -763,16 +748,11 @@ static inline NSString * AFMultipartFormFinalBoundary() {
} }
- (void)dealloc { - (void)dealloc {
[_request release];
if (_outputStream) { if (_outputStream) {
[_outputStream close]; [_outputStream close];
[_outputStream release];
_outputStream = nil;
} }
[_temporaryFilePath release];
[super dealloc];
} }
- (NSMutableURLRequest *)requestByFinalizingMultipartFormData { - (NSMutableURLRequest *)requestByFinalizingMultipartFormData {
@ -847,7 +827,7 @@ static inline NSString * AFMultipartFormFinalBoundary() {
[userInfo setValue:fileURL forKey:NSURLErrorFailingURLErrorKey]; [userInfo setValue:fileURL forKey:NSURLErrorFailingURLErrorKey];
[userInfo setValue:NSLocalizedString(@"Expected URL to be a file URL", nil) forKey:NSLocalizedFailureReasonErrorKey]; [userInfo setValue:NSLocalizedString(@"Expected URL to be a file URL", nil) forKey:NSLocalizedFailureReasonErrorKey];
if (error != NULL) { if (error != NULL) {
*error = [[[NSError alloc] initWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:userInfo] autorelease]; *error = [[NSError alloc] initWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:userInfo];
} }
return NO; return NO;

View file

@ -35,7 +35,7 @@
/** /**
The last HTTP response received by the operation's connection. The last HTTP response received by the operation's connection.
*/ */
@property (readonly, nonatomic, retain) NSHTTPURLResponse *response; @property (readonly, nonatomic, strong) NSHTTPURLResponse *response;
///---------------------------------------------------------- ///----------------------------------------------------------
/// @name Managing And Checking For Acceptable HTTP Responses /// @name Managing And Checking For Acceptable HTTP Responses

View file

@ -23,11 +23,18 @@
#import "AFHTTPRequestOperation.h" #import "AFHTTPRequestOperation.h"
#import <objc/runtime.h> #import <objc/runtime.h>
// Workaround for change in imp_implementationWithBlock()
#ifdef __IPHONE_6_0
#define AF_CAST_TO_BLOCK id
#else
#define AF_CAST_TO_BLOCK __bridge void *
#endif
NSSet * AFContentTypesFromHTTPHeader(NSString *string) { NSSet * AFContentTypesFromHTTPHeader(NSString *string) {
static NSCharacterSet *_skippedCharacterSet = nil; static NSCharacterSet *_skippedCharacterSet = nil;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
_skippedCharacterSet = [[NSCharacterSet characterSetWithCharactersInString:@" ,"] retain]; _skippedCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@" ,"];
}); });
if (!string) { if (!string) {
@ -52,11 +59,10 @@ NSSet * AFContentTypesFromHTTPHeader(NSString *string) {
return [NSSet setWithSet:mutableContentTypes]; return [NSSet setWithSet:mutableContentTypes];
} }
static void AFSwizzleClassMethodWithImplementation(Class klass, SEL selector, IMP implementation) { static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL selector, id block) {
Method originalMethod = class_getClassMethod(klass, selector); Method originalMethod = class_getClassMethod(klass, selector);
if (method_getImplementation(originalMethod) != implementation) { IMP implementation = imp_implementationWithBlock((AF_CAST_TO_BLOCK)block);
class_replaceMethod(objc_getMetaClass([NSStringFromClass(klass) UTF8String]), selector, implementation, method_getTypeEncoding(originalMethod)); class_replaceMethod(objc_getMetaClass([NSStringFromClass(klass) UTF8String]), selector, implementation, method_getTypeEncoding(originalMethod));
}
} }
static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) { static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
@ -92,9 +98,9 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
#pragma mark - #pragma mark -
@interface AFHTTPRequestOperation () @interface AFHTTPRequestOperation ()
@property (readwrite, nonatomic, retain) NSURLRequest *request; @property (readwrite, nonatomic, strong) NSURLRequest *request;
@property (readwrite, nonatomic, retain) NSHTTPURLResponse *response; @property (readwrite, nonatomic, strong) NSHTTPURLResponse *response;
@property (readwrite, nonatomic, retain) NSError *HTTPError; @property (readwrite, nonatomic, strong) NSError *HTTPError;
@property (assign) long long totalContentLength; @property (assign) long long totalContentLength;
@property (assign) long long offsetContentLength; @property (assign) long long offsetContentLength;
@end @end
@ -109,8 +115,6 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
@dynamic response; @dynamic response;
- (void)dealloc { - (void)dealloc {
[_HTTPError release];
if (_successCallbackQueue) { if (_successCallbackQueue) {
dispatch_release(_successCallbackQueue); dispatch_release(_successCallbackQueue);
_successCallbackQueue = NULL; _successCallbackQueue = NULL;
@ -120,8 +124,6 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
dispatch_release(_failureCallbackQueue); dispatch_release(_failureCallbackQueue);
_failureCallbackQueue = NULL; _failureCallbackQueue = NULL;
} }
[super dealloc];
} }
- (NSError *)error { - (NSError *)error {
@ -136,12 +138,12 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
if (![self hasAcceptableStatusCode]) { if (![self hasAcceptableStatusCode]) {
NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200; NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200;
[userInfo setValue:[NSString stringWithFormat:NSLocalizedString(@"Expected status code in (%@), got %d", nil), AFStringFromIndexSet([[self class] acceptableStatusCodes]), statusCode] forKey:NSLocalizedDescriptionKey]; [userInfo setValue:[NSString stringWithFormat:NSLocalizedString(@"Expected status code in (%@), got %d", nil), AFStringFromIndexSet([[self class] acceptableStatusCodes]), statusCode] forKey:NSLocalizedDescriptionKey];
self.HTTPError = [[[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadServerResponse userInfo:userInfo] autorelease]; self.HTTPError = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadServerResponse userInfo:userInfo];
} else if (![self hasAcceptableContentType]) { } else if (![self hasAcceptableContentType]) {
// Don't invalidate content type if there is no content // Don't invalidate content type if there is no content
if ([self.responseData length] > 0) { if ([self.responseData length] > 0) {
[userInfo setValue:[NSString stringWithFormat:NSLocalizedString(@"Expected content type %@, got %@", nil), [[self class] acceptableContentTypes], [self.response MIMEType]] forKey:NSLocalizedDescriptionKey]; [userInfo setValue:[NSString stringWithFormat:NSLocalizedString(@"Expected content type %@, got %@", nil), [[self class] acceptableContentTypes], [self.response MIMEType]] forKey:NSLocalizedDescriptionKey];
self.HTTPError = [[[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo] autorelease]; self.HTTPError = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo];
} }
} }
} }
@ -162,7 +164,7 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
offset = [[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length]; offset = [[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length];
} }
NSMutableURLRequest *mutableURLRequest = [[self.request mutableCopy] autorelease]; NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy];
if ([[self.response allHeaderFields] valueForKey:@"ETag"]) { if ([[self.response allHeaderFields] valueForKey:@"ETag"]) {
[mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"]; [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"];
} }
@ -228,6 +230,9 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
// completion block is manually nilled out in AFURLConnectionOperation to break the retain cycle.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
self.completionBlock = ^ { self.completionBlock = ^ {
if ([self isCancelled]) { if ([self isCancelled]) {
return; return;
@ -247,24 +252,21 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
} }
} }
}; };
#pragma clang diagnostic pop
} }
#pragma mark - AFHTTPRequestOperation #pragma mark - AFHTTPRequestOperation
static id AFStaticClassValueImplementation(id self, SEL _cmd) {
return objc_getAssociatedObject([self class], _cmd);
}
+ (NSIndexSet *)acceptableStatusCodes { + (NSIndexSet *)acceptableStatusCodes {
return [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; return [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)];
} }
+ (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes { + (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes {
NSMutableIndexSet *mutableStatusCodes = [[[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]] autorelease]; NSMutableIndexSet *mutableStatusCodes = [[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]];
[mutableStatusCodes addIndexes:statusCodes]; [mutableStatusCodes addIndexes:statusCodes];
SEL selector = @selector(acceptableStatusCodes); AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(id _self) {
AFSwizzleClassMethodWithImplementation([self class], selector, (IMP)AFStaticClassValueImplementation); return mutableStatusCodes;
objc_setAssociatedObject([self class], selector, mutableStatusCodes, OBJC_ASSOCIATION_COPY_NONATOMIC); });
} }
+ (NSSet *)acceptableContentTypes { + (NSSet *)acceptableContentTypes {
@ -272,11 +274,11 @@ static id AFStaticClassValueImplementation(id self, SEL _cmd) {
} }
+ (void)addAcceptableContentTypes:(NSSet *)contentTypes { + (void)addAcceptableContentTypes:(NSSet *)contentTypes {
NSMutableSet *mutableContentTypes = [[[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES] autorelease]; NSMutableSet *mutableContentTypes = [[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES];
[mutableContentTypes unionSet:contentTypes]; [mutableContentTypes unionSet:contentTypes];
SEL selector = @selector(acceptableContentTypes); AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(id _self) {
AFSwizzleClassMethodWithImplementation([self class], selector, (IMP)AFStaticClassValueImplementation); return mutableContentTypes;
objc_setAssociatedObject([self class], selector, mutableContentTypes, OBJC_ASSOCIATION_COPY_NONATOMIC); });
} }
+ (BOOL)canProcessRequest:(NSURLRequest *)request { + (BOOL)canProcessRequest:(NSURLRequest *)request {

View file

@ -55,7 +55,7 @@
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. 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 __IPHONE_OS_VERSION_MIN_REQUIRED
@property (readonly, nonatomic, retain) UIImage *responseImage; @property (readonly, nonatomic) UIImage *responseImage;
#elif __MAC_OS_X_VERSION_MIN_REQUIRED #elif __MAC_OS_X_VERSION_MIN_REQUIRED
@property (readonly, nonatomic, retain) NSImage *responseImage; @property (readonly, nonatomic, retain) NSImage *responseImage;
#endif #endif

View file

@ -33,7 +33,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
@interface AFImageRequestOperation () @interface AFImageRequestOperation ()
#if __IPHONE_OS_VERSION_MIN_REQUIRED #if __IPHONE_OS_VERSION_MIN_REQUIRED
@property (readwrite, nonatomic, retain) UIImage *responseImage; @property (readwrite, nonatomic) UIImage *responseImage;
#elif __MAC_OS_X_VERSION_MIN_REQUIRED #elif __MAC_OS_X_VERSION_MIN_REQUIRED
@property (readwrite, nonatomic, retain) NSImage *responseImage; @property (readwrite, nonatomic, retain) NSImage *responseImage;
#endif #endif
@ -74,7 +74,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
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 *requestOperation = [[[AFImageRequestOperation alloc] initWithRequest:urlRequest] autorelease]; AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
if (success) { if (success) {
UIImage *image = responseObject; UIImage *image = responseObject;
@ -82,7 +82,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
dispatch_async(image_request_operation_processing_queue(), ^(void) { dispatch_async(image_request_operation_processing_queue(), ^(void) {
UIImage *processedImage = imageProcessingBlock(image); UIImage *processedImage = imageProcessingBlock(image);
dispatch_async(requestOperation.successCallbackQueue ? requestOperation.successCallbackQueue : dispatch_get_main_queue(), ^(void) { dispatch_async(requestOperation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) {
success(operation.request, operation.response, processedImage); success(operation.request, operation.response, processedImage);
}); });
}); });
@ -105,7 +105,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
{ {
AFImageRequestOperation *requestOperation = [[[AFImageRequestOperation alloc] initWithRequest:urlRequest] autorelease]; AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
if (success) { if (success) {
NSImage *image = responseObject; NSImage *image = responseObject;
@ -113,7 +113,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
dispatch_async(image_request_operation_processing_queue(), ^(void) { dispatch_async(image_request_operation_processing_queue(), ^(void) {
NSImage *processedImage = imageProcessingBlock(image); NSImage *processedImage = imageProcessingBlock(image);
dispatch_async(requestOperation.successCallbackQueue ? requestOperation.successCallbackQueue : dispatch_get_main_queue(), ^(void) { dispatch_async(requestOperation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) {
success(operation.request, operation.response, processedImage); success(operation.request, operation.response, processedImage);
}); });
}); });
@ -144,10 +144,6 @@ static dispatch_queue_t image_request_operation_processing_queue() {
return self; return self;
} }
- (void)dealloc {
[_responseImage release];
[super dealloc];
}
#if __IPHONE_OS_VERSION_MIN_REQUIRED #if __IPHONE_OS_VERSION_MIN_REQUIRED
- (UIImage *)responseImage { - (UIImage *)responseImage {
@ -177,9 +173,8 @@ static dispatch_queue_t image_request_operation_processing_queue() {
if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) { if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) {
// Ensure that the image is set to it's correct pixel width and height // Ensure that the image is set to it's correct pixel width and height
NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:self.responseData]; NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:self.responseData];
self.responseImage = [[[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])] autorelease]; self.responseImage = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])];
[self.responseImage addRepresentation:bitimage]; [self.responseImage addRepresentation:bitimage];
[bitimage release];
} }
return _responseImage; return _responseImage;
@ -205,6 +200,8 @@ static dispatch_queue_t image_request_operation_processing_queue() {
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
self.completionBlock = ^ { self.completionBlock = ^ {
if ([self isCancelled]) { if ([self isCancelled]) {
return; return;
@ -213,7 +210,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
dispatch_async(image_request_operation_processing_queue(), ^(void) { dispatch_async(image_request_operation_processing_queue(), ^(void) {
if (self.error) { if (self.error) {
if (failure) { if (failure) {
dispatch_async(self.failureCallbackQueue ? self.failureCallbackQueue : dispatch_get_main_queue(), ^{ dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
failure(self, self.error); failure(self, self.error);
}); });
} }
@ -227,13 +224,14 @@ static dispatch_queue_t image_request_operation_processing_queue() {
image = self.responseImage; image = self.responseImage;
dispatch_async(self.successCallbackQueue ? self.successCallbackQueue : dispatch_get_main_queue(), ^{ dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{
success(self, image); success(self, image);
}); });
} }
} }
}); });
}; };
#pragma clang diagnostic pop
} }
@end @end

View file

@ -44,7 +44,7 @@
/** /**
A JSON object constructed from the response data. If an error occurs while parsing, `nil` will be returned, and the `error` property will be set to the error. A JSON object constructed from the response data. If an error occurs while parsing, `nil` will be returned, and the `error` property will be set to the error.
*/ */
@property (readonly, nonatomic, retain) id responseJSON; @property (readonly, nonatomic) id responseJSON;
///---------------------------------- ///----------------------------------
/// @name Creating Request Operations /// @name Creating Request Operations

View file

@ -21,7 +21,6 @@
// THE SOFTWARE. // THE SOFTWARE.
#import "AFJSONRequestOperation.h" #import "AFJSONRequestOperation.h"
#import "AFJSONUtilities.h"
static dispatch_queue_t af_json_request_operation_processing_queue; static dispatch_queue_t af_json_request_operation_processing_queue;
static dispatch_queue_t json_request_operation_processing_queue() { static dispatch_queue_t json_request_operation_processing_queue() {
@ -33,8 +32,8 @@ static dispatch_queue_t json_request_operation_processing_queue() {
} }
@interface AFJSONRequestOperation () @interface AFJSONRequestOperation ()
@property (readwrite, nonatomic, retain) id responseJSON; @property (readwrite, nonatomic) id responseJSON;
@property (readwrite, nonatomic, retain) NSError *JSONError; @property (readwrite, nonatomic) NSError *JSONError;
@end @end
@implementation AFJSONRequestOperation @implementation AFJSONRequestOperation
@ -45,7 +44,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
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, id JSON))failure failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure
{ {
AFJSONRequestOperation *requestOperation = [[[self alloc] initWithRequest:urlRequest] autorelease]; AFJSONRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
if (success) { if (success) {
success(operation.request, operation.response, responseObject); success(operation.request, operation.response, responseObject);
@ -59,11 +58,6 @@ static dispatch_queue_t json_request_operation_processing_queue() {
return requestOperation; return requestOperation;
} }
- (void)dealloc {
[_responseJSON release];
[_JSONError release];
[super dealloc];
}
- (id)responseJSON { - (id)responseJSON {
if (!_responseJSON && [self.responseData length] > 0 && [self isFinished] && !self.JSONError) { if (!_responseJSON && [self.responseData length] > 0 && [self isFinished] && !self.JSONError) {
@ -72,7 +66,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
if ([self.responseData length] == 0) { if ([self.responseData length] == 0) {
self.responseJSON = nil; self.responseJSON = nil;
} else { } else {
self.responseJSON = AFJSONDecode(self.responseData, &error); self.responseJSON = [NSJSONSerialization JSONObjectWithData:self.responseData options:0 error:&error];
} }
self.JSONError = error; self.JSONError = error;
@ -102,7 +96,9 @@ static dispatch_queue_t json_request_operation_processing_queue() {
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
self.completionBlock = ^ { #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
self.completionBlock = ^ {
if ([self isCancelled]) { if ([self isCancelled]) {
return; return;
} }
@ -125,7 +121,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
} }
} else { } else {
if (success) { if (success) {
dispatch_async(self.successCallbackQueue ? : dispatch_get_main_queue(), ^{ dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{
success(self, JSON); success(self, JSON);
}); });
} }
@ -133,6 +129,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
}); });
} }
}; };
#pragma clang diagnostic pop
} }
@end @end

View file

@ -1,26 +0,0 @@
// AFJSONUtilities.h
//
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
extern NSData * AFJSONEncode(id object, NSError **error);
extern id AFJSONDecode(NSData *data, NSError **error);

View file

@ -1,217 +0,0 @@
// AFJSONUtilities.m
//
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "AFJSONUtilities.h"
NSData * AFJSONEncode(id object, NSError **error) {
NSData *data = nil;
SEL _JSONKitSelector = NSSelectorFromString(@"JSONDataWithOptions:error:");
SEL _YAJLSelector = NSSelectorFromString(@"yajl_JSONString");
id _SBJsonWriterClass = NSClassFromString(@"SBJsonWriter");
SEL _SBJsonWriterSelector = NSSelectorFromString(@"dataWithObject:");
id _NXJsonSerializerClass = NSClassFromString(@"NXJsonSerializer");
SEL _NXJsonSerializerSelector = NSSelectorFromString(@"serialize:");
id _NSJSONSerializationClass = NSClassFromString(@"NSJSONSerialization");
SEL _NSJSONSerializationSelector = NSSelectorFromString(@"dataWithJSONObject:options:error:");
#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_
if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) {
goto _af_nsjson_encode;
}
#endif
if (_JSONKitSelector && [object respondsToSelector:_JSONKitSelector]) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[object methodSignatureForSelector:_JSONKitSelector]];
invocation.target = object;
invocation.selector = _JSONKitSelector;
NSUInteger serializeOptionFlags = 0;
[invocation setArgument:&serializeOptionFlags atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
if (error != NULL) {
[invocation setArgument:error atIndex:3];
}
[invocation invoke];
[invocation getReturnValue:&data];
} else if (_SBJsonWriterClass && [_SBJsonWriterClass instancesRespondToSelector:_SBJsonWriterSelector]) {
id writer = [[_SBJsonWriterClass alloc] init];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[writer methodSignatureForSelector:_SBJsonWriterSelector]];
invocation.target = writer;
invocation.selector = _SBJsonWriterSelector;
[invocation setArgument:&object atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
[invocation invoke];
[invocation getReturnValue:&data];
[writer release];
} else if (_YAJLSelector && [object respondsToSelector:_YAJLSelector]) {
@try {
NSString *JSONString = nil;
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[object methodSignatureForSelector:_YAJLSelector]];
invocation.target = object;
invocation.selector = _YAJLSelector;
[invocation invoke];
[invocation getReturnValue:&JSONString];
data = [JSONString dataUsingEncoding:NSUTF8StringEncoding];
}
@catch (NSException *exception) {
*error = [[[NSError alloc] initWithDomain:NSStringFromClass([exception class]) code:0 userInfo:[exception userInfo]] autorelease];
}
} else if (_NXJsonSerializerClass && [_NXJsonSerializerClass respondsToSelector:_NXJsonSerializerSelector]) {
NSString *JSONString = nil;
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NXJsonSerializerClass methodSignatureForSelector:_NXJsonSerializerSelector]];
invocation.target = _NXJsonSerializerClass;
invocation.selector = _NXJsonSerializerSelector;
[invocation setArgument:&object atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
[invocation invoke];
[invocation getReturnValue:&JSONString];
data = [JSONString dataUsingEncoding:NSUTF8StringEncoding];
} else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) {
#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_
_af_nsjson_encode:;
#endif
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]];
invocation.target = _NSJSONSerializationClass;
invocation.selector = _NSJSONSerializationSelector;
[invocation setArgument:&object atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
NSUInteger writeOptions = 0;
[invocation setArgument:&writeOptions atIndex:3];
if (error != NULL) {
[invocation setArgument:error atIndex:4];
}
[invocation invoke];
[invocation getReturnValue:&data];
} else {
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:NSLocalizedString(@"Please either target a platform that supports NSJSONSerialization or add one of the following libraries to your project: JSONKit, SBJSON, or YAJL", nil) forKey:NSLocalizedRecoverySuggestionErrorKey];
[[NSException exceptionWithName:NSInternalInconsistencyException reason:NSLocalizedString(@"No JSON generation functionality available", nil) userInfo:userInfo] raise];
}
return data;
}
id AFJSONDecode(NSData *data, NSError **error) {
id JSON = nil;
SEL _JSONKitSelector = NSSelectorFromString(@"objectFromJSONDataWithParseOptions:error:");
SEL _YAJLSelector = NSSelectorFromString(@"yajl_JSONWithOptions:error:");
id _SBJSONParserClass = NSClassFromString(@"SBJsonParser");
SEL _SBJSONParserSelector = NSSelectorFromString(@"objectWithData:");
id _NSJSONSerializationClass = NSClassFromString(@"NSJSONSerialization");
SEL _NSJSONSerializationSelector = NSSelectorFromString(@"JSONObjectWithData:options:error:");
id _NXJsonParserClass = NSClassFromString(@"NXJsonParser");
SEL _NXJsonParserSelector = NSSelectorFromString(@"parseData:error:ignoreNulls:");
#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_
if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) {
goto _af_nsjson_decode;
}
#endif
if (_JSONKitSelector && [data respondsToSelector:_JSONKitSelector]) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[data methodSignatureForSelector:_JSONKitSelector]];
invocation.target = data;
invocation.selector = _JSONKitSelector;
NSUInteger parseOptionFlags = 0;
[invocation setArgument:&parseOptionFlags atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
if (error != NULL) {
[invocation setArgument:&error atIndex:3];
}
[invocation invoke];
[invocation getReturnValue:&JSON];
} else if (_SBJSONParserClass && [_SBJSONParserClass instancesRespondToSelector:_SBJSONParserSelector]) {
id parser = [[_SBJSONParserClass alloc] init];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[parser methodSignatureForSelector:_SBJSONParserSelector]];
invocation.target = parser;
invocation.selector = _SBJSONParserSelector;
[invocation setArgument:&data atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
[invocation invoke];
[invocation getReturnValue:&JSON];
[parser release];
} else if (_YAJLSelector && [data respondsToSelector:_YAJLSelector]) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[data methodSignatureForSelector:_YAJLSelector]];
invocation.target = data;
invocation.selector = _YAJLSelector;
NSUInteger yajlParserOptions = 0;
[invocation setArgument:&yajlParserOptions atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
if (error != NULL) {
[invocation setArgument:&error atIndex:3];
}
[invocation invoke];
[invocation getReturnValue:&JSON];
} else if (_NXJsonParserClass && [_NXJsonParserClass respondsToSelector:_NXJsonParserSelector]) {
NSNumber *nullOption = [NSNumber numberWithBool:YES];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NXJsonParserClass methodSignatureForSelector:_NXJsonParserSelector]];
invocation.target = _NXJsonParserClass;
invocation.selector = _NXJsonParserSelector;
[invocation setArgument:&data atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
if (error != NULL) {
[invocation setArgument:&error atIndex:3];
}
[invocation setArgument:&nullOption atIndex:4];
[invocation invoke];
[invocation getReturnValue:&JSON];
} else if (_NSJSONSerializationClass && [_NSJSONSerializationClass respondsToSelector:_NSJSONSerializationSelector]) {
#ifdef _AFNETWORKING_PREFER_NSJSONSERIALIZATION_
_af_nsjson_decode:;
#endif
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[_NSJSONSerializationClass methodSignatureForSelector:_NSJSONSerializationSelector]];
invocation.target = _NSJSONSerializationClass;
invocation.selector = _NSJSONSerializationSelector;
[invocation setArgument:&data atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
NSUInteger readOptions = 0;
[invocation setArgument:&readOptions atIndex:3];
if (error != NULL) {
[invocation setArgument:&error atIndex:4];
}
[invocation invoke];
[invocation getReturnValue:&JSON];
} else {
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:NSLocalizedString(@"Please either target a platform that supports NSJSONSerialization or add one of the following libraries to your project: JSONKit, SBJSON, or YAJL", nil) forKey:NSLocalizedRecoverySuggestionErrorKey];
[[NSException exceptionWithName:NSInternalInconsistencyException reason:NSLocalizedString(@"No JSON parsing functionality available", nil) userInfo:userInfo] raise];
}
return JSON;
}

View file

@ -72,9 +72,7 @@ static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17;
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
[_activityIndicatorVisibilityTimer invalidate]; [_activityIndicatorVisibilityTimer invalidate];
[_activityIndicatorVisibilityTimer release]; _activityIndicatorVisibilityTimer = nil;
[super dealloc];
} }
- (void)updateNetworkActivityIndicatorVisibilityDelayed { - (void)updateNetworkActivityIndicatorVisibilityDelayed {

View file

@ -41,7 +41,7 @@
/** /**
An object deserialized from a plist constructed using the response data. An object deserialized from a plist constructed using the response data.
*/ */
@property (readonly, nonatomic, retain) id responsePropertyList; @property (readonly, nonatomic) id responsePropertyList;
///-------------------------------------- ///--------------------------------------
/// @name Managing Property List Behavior /// @name Managing Property List Behavior

View file

@ -32,9 +32,9 @@ static dispatch_queue_t property_list_request_operation_processing_queue() {
} }
@interface AFPropertyListRequestOperation () @interface AFPropertyListRequestOperation ()
@property (readwrite, nonatomic, retain) id responsePropertyList; @property (readwrite, nonatomic) id responsePropertyList;
@property (readwrite, nonatomic, assign) NSPropertyListFormat propertyListFormat; @property (readwrite, nonatomic, assign) NSPropertyListFormat propertyListFormat;
@property (readwrite, nonatomic, retain) NSError *propertyListError; @property (readwrite, nonatomic) NSError *propertyListError;
@end @end
@implementation AFPropertyListRequestOperation @implementation AFPropertyListRequestOperation
@ -47,7 +47,7 @@ static dispatch_queue_t property_list_request_operation_processing_queue() {
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure
{ {
AFPropertyListRequestOperation *requestOperation = [[[self alloc] initWithRequest:request] autorelease]; AFPropertyListRequestOperation *requestOperation = [[self alloc] initWithRequest:request];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
if (success) { if (success) {
success(operation.request, operation.response, responseObject); success(operation.request, operation.response, responseObject);
@ -72,11 +72,6 @@ static dispatch_queue_t property_list_request_operation_processing_queue() {
return self; return self;
} }
- (void)dealloc {
[_responsePropertyList release];
[_propertyListError release];
[super dealloc];
}
- (id)responsePropertyList { - (id)responsePropertyList {
if (!_responsePropertyList && [self.responseData length] > 0 && [self isFinished]) { if (!_responsePropertyList && [self.responseData length] > 0 && [self isFinished]) {
@ -111,6 +106,8 @@ static dispatch_queue_t property_list_request_operation_processing_queue() {
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
self.completionBlock = ^ { self.completionBlock = ^ {
if ([self isCancelled]) { if ([self isCancelled]) {
return; return;
@ -142,6 +139,7 @@ static dispatch_queue_t property_list_request_operation_processing_queue() {
}); });
} }
}; };
#pragma clang diagnostic pop
} }
@end @end

View file

@ -71,7 +71,7 @@
- A copy of an operation will not include the `outputStream` of the original. - A copy of an operation will not include the `outputStream` of the original.
- Operation copies do not include `completionBlock`. `completionBlock` often strongly captures a reference to `self`, which, perhaps surprisingly, would otherwise point to the _original_ operation when copied. - Operation copies do not include `completionBlock`. `completionBlock` often strongly captures a reference to `self`, which, perhaps surprisingly, would otherwise point to the _original_ operation when copied.
*/ */
@interface AFURLConnectionOperation : NSOperation <NSCoding, NSCopying> @interface AFURLConnectionOperation : NSOperation <NSURLConnectionDelegate, NSURLConnectionDataDelegate, NSCoding, NSCopying>
///------------------------------- ///-------------------------------
/// @name Accessing Run Loop Modes /// @name Accessing Run Loop Modes
@ -80,7 +80,7 @@
/** /**
The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing `NSRunLoopCommonModes`. The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing `NSRunLoopCommonModes`.
*/ */
@property (nonatomic, retain) NSSet *runLoopModes; @property (nonatomic, strong) NSSet *runLoopModes;
///----------------------------------------- ///-----------------------------------------
/// @name Getting URL Connection Information /// @name Getting URL Connection Information
@ -89,17 +89,17 @@
/** /**
The request used by the operation's connection. The request used by the operation's connection.
*/ */
@property (readonly, nonatomic, retain) NSURLRequest *request; @property (readonly, nonatomic, strong) NSURLRequest *request;
/** /**
The last response received by the operation's connection. The last response received by the operation's connection.
*/ */
@property (readonly, nonatomic, retain) NSURLResponse *response; @property (readonly, nonatomic, strong) NSURLResponse *response;
/** /**
The error, if any, that occurred in the lifecycle of the request. The error, if any, that occurred in the lifecycle of the request.
*/ */
@property (readonly, nonatomic, retain) NSError *error; @property (readonly, nonatomic, strong) NSError *error;
///---------------------------- ///----------------------------
/// @name Getting Response Data /// @name Getting Response Data
@ -108,7 +108,7 @@
/** /**
The data received during the request. The data received during the request.
*/ */
@property (readonly, nonatomic, retain) NSData *responseData; @property (readonly, nonatomic, strong) NSData *responseData;
/** /**
The string representation of the response data. The string representation of the response data.
@ -126,14 +126,14 @@
@discussion This property acts as a proxy to the `HTTPBodyStream` property of `request`. @discussion This property acts as a proxy to the `HTTPBodyStream` property of `request`.
*/ */
@property (nonatomic, retain) NSInputStream *inputStream; @property (nonatomic, strong) NSInputStream *inputStream;
/** /**
The output stream that is used to write data received until the request is finished. 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. @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.
*/ */
@property (nonatomic, retain) NSOutputStream *outputStream; @property (nonatomic, strong) NSOutputStream *outputStream;
///------------------------------------------------------ ///------------------------------------------------------
/// @name Initializing an AFURLConnectionOperation Object /// @name Initializing an AFURLConnectionOperation Object
@ -241,40 +241,6 @@
*/ */
- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block; - (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block;
///---------------------------------------
/// @name NSURLConnection Delegate Methods
/// @discussion NSURLConnection delegate methods were part of an informal protocol until iOS 5 & Mac OS 10.7, so the method signatures are declared here in order to allow subclasses to override these methods and call back to the super implementation.
///---------------------------------------
- (BOOL)connection:(NSURLConnection *)connection
canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace;
- (void)connection:(NSURLConnection *)connection
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
- (NSURLRequest *)connection:(NSURLConnection *)connection
willSendRequest:(NSURLRequest *)request
redirectResponse:(NSURLResponse *)redirectResponse;
- (void)connection:(NSURLConnection *)connection
didSendBodyData:(NSInteger)bytesWritten
totalBytesWritten:(NSInteger)totalBytesWritten
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
- (void)connection:(NSURLConnection *)connection
didReceiveResponse:(NSURLResponse *)response;
- (void)connection:(NSURLConnection *)connection
didReceiveData:(NSData *)data;
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
- (void)connection:(NSURLConnection *)connection
didFailWithError:(NSError *)error;
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection
willCacheResponse:(NSCachedURLResponse *)cachedResponse;
@end @end
///---------------- ///----------------

View file

@ -102,12 +102,12 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
@interface AFURLConnectionOperation () @interface AFURLConnectionOperation ()
@property (readwrite, nonatomic, assign) AFOperationState state; @property (readwrite, nonatomic, assign) AFOperationState state;
@property (readwrite, nonatomic, assign, getter = isCancelled) BOOL cancelled; @property (readwrite, nonatomic, assign, getter = isCancelled) BOOL cancelled;
@property (readwrite, nonatomic, retain) NSRecursiveLock *lock; @property (readwrite, nonatomic, strong) NSRecursiveLock *lock;
@property (readwrite, nonatomic, retain) NSURLConnection *connection; @property (readwrite, nonatomic, strong) NSURLConnection *connection;
@property (readwrite, nonatomic, retain) NSURLRequest *request; @property (readwrite, nonatomic, strong) NSURLRequest *request;
@property (readwrite, nonatomic, retain) NSURLResponse *response; @property (readwrite, nonatomic, strong) NSURLResponse *response;
@property (readwrite, nonatomic, retain) NSError *error; @property (readwrite, nonatomic, strong) NSError *error;
@property (readwrite, nonatomic, retain) NSData *responseData; @property (readwrite, nonatomic, strong) NSData *responseData;
@property (readwrite, nonatomic, copy) NSString *responseString; @property (readwrite, nonatomic, copy) NSString *responseString;
@property (readwrite, nonatomic, assign) long long totalBytesRead; @property (readwrite, nonatomic, assign) long long totalBytesRead;
@property (readwrite, nonatomic, assign) AFBackgroundTaskIdentifier backgroundTaskIdentifier; @property (readwrite, nonatomic, assign) AFBackgroundTaskIdentifier backgroundTaskIdentifier;
@ -171,7 +171,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
return nil; return nil;
} }
self.lock = [[[NSRecursiveLock alloc] init] autorelease]; self.lock = [[NSRecursiveLock alloc] init];
self.lock.name = kAFNetworkingLockName; self.lock.name = kAFNetworkingLockName;
self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes];
@ -190,20 +190,8 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
} }
- (void)dealloc { - (void)dealloc {
[_lock release];
[_runLoopModes release];
[_request release];
[_response release];
[_error release];
[_responseData release];
[_responseString release];
if (_outputStream) { if (_outputStream) {
[_outputStream close]; [_outputStream close];
[_outputStream release];
_outputStream = nil; _outputStream = nil;
} }
@ -213,17 +201,6 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
_backgroundTaskIdentifier = UIBackgroundTaskInvalid; _backgroundTaskIdentifier = UIBackgroundTaskInvalid;
} }
#endif #endif
[_uploadProgress release];
[_downloadProgress release];
[_authenticationChallenge release];
[_authenticationAgainstProtectionSpace release];
[_cacheResponse release];
[_redirectResponse release];
[_connection release];
[super dealloc];
} }
- (NSString *)description { - (NSString *)description {
@ -235,7 +212,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
if (!block) { if (!block) {
[super setCompletionBlock:nil]; [super setCompletionBlock:nil];
} else { } else {
__block id _blockSelf = self; __unsafe_unretained id _blockSelf = self;
[super setCompletionBlock:^ { [super setCompletionBlock:^ {
block(); block();
[_blockSelf setCompletionBlock:nil]; [_blockSelf setCompletionBlock:nil];
@ -250,7 +227,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
- (void)setInputStream:(NSInputStream *)inputStream { - (void)setInputStream:(NSInputStream *)inputStream {
[self willChangeValueForKey:@"inputStream"]; [self willChangeValueForKey:@"inputStream"];
NSMutableURLRequest *mutableRequest = [[self.request mutableCopy] autorelease]; NSMutableURLRequest *mutableRequest = [self.request mutableCopy];
mutableRequest.HTTPBodyStream = inputStream; mutableRequest.HTTPBodyStream = inputStream;
self.request = mutableRequest; self.request = mutableRequest;
[self didChangeValueForKey:@"inputStream"]; [self didChangeValueForKey:@"inputStream"];
@ -262,11 +239,9 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
} }
[self willChangeValueForKey:@"outputStream"]; [self willChangeValueForKey:@"outputStream"];
[outputStream retain];
if (_outputStream) { if (_outputStream) {
[_outputStream close]; [_outputStream close];
[_outputStream release];
} }
_outputStream = outputStream; _outputStream = outputStream;
[self didChangeValueForKey:@"outputStream"]; [self didChangeValueForKey:@"outputStream"];
@ -347,10 +322,10 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
if (!_responseString && self.response && self.responseData) { if (!_responseString && self.response && self.responseData) {
NSStringEncoding textEncoding = NSUTF8StringEncoding; NSStringEncoding textEncoding = NSUTF8StringEncoding;
if (self.response.textEncodingName) { if (self.response.textEncodingName) {
textEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)self.response.textEncodingName)); textEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName));
} }
self.responseString = [[[NSString alloc] initWithData:self.responseData encoding:textEncoding] autorelease]; self.responseString = [[NSString alloc] initWithData:self.responseData encoding:textEncoding];
} }
[self.lock unlock]; [self.lock unlock];
@ -423,7 +398,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
if ([self isCancelled]) { if ([self isCancelled]) {
[self finish]; [self finish];
} else { } else {
self.connection = [[[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO] autorelease]; self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO];
NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
for (NSString *runLoopMode in self.runLoopModes) { for (NSString *runLoopMode in self.runLoopModes) {
@ -503,8 +478,8 @@ didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
if ([challenge previousFailureCount] == 0) { if ([challenge previousFailureCount] == 0) {
NSURLCredential *credential = nil; NSURLCredential *credential = nil;
NSString *username = [(NSString *)CFURLCopyUserName((CFURLRef)[self.request URL]) autorelease]; NSString *username = (__bridge_transfer NSString *)CFURLCopyUserName((__bridge CFURLRef)[self.request URL]);
NSString *password = [(NSString *)CFURLCopyPassword((CFURLRef)[self.request URL]) autorelease]; NSString *password = (__bridge_transfer NSString *)CFURLCopyPassword((__bridge CFURLRef)[self.request URL]);
if (username && password) { if (username && password) {
credential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceNone]; credential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceNone];

View file

@ -48,7 +48,7 @@
/** /**
An `NSXMLParser` object constructed from the response data. An `NSXMLParser` object constructed from the response data.
*/ */
@property (readonly, nonatomic, retain) NSXMLParser *responseXMLParser; @property (readonly, nonatomic) NSXMLParser *responseXMLParser;
#if __MAC_OS_X_VERSION_MIN_REQUIRED #if __MAC_OS_X_VERSION_MIN_REQUIRED
/** /**

View file

@ -34,11 +34,11 @@ static dispatch_queue_t xml_request_operation_processing_queue() {
} }
@interface AFXMLRequestOperation () @interface AFXMLRequestOperation ()
@property (readwrite, nonatomic, retain) NSXMLParser *responseXMLParser; @property (readwrite, nonatomic) NSXMLParser *responseXMLParser;
#if __MAC_OS_X_VERSION_MIN_REQUIRED #if __MAC_OS_X_VERSION_MIN_REQUIRED
@property (readwrite, nonatomic, retain) NSXMLDocument *responseXMLDocument; @property (readwrite, nonatomic, retain) NSXMLDocument *responseXMLDocument;
#endif #endif
@property (readwrite, nonatomic, retain) NSError *XMLError; @property (readwrite, nonatomic) NSError *XMLError;
@end @end
@implementation AFXMLRequestOperation @implementation AFXMLRequestOperation
@ -52,7 +52,7 @@ static dispatch_queue_t xml_request_operation_processing_queue() {
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure
{ {
AFXMLRequestOperation *requestOperation = [[[self alloc] initWithRequest:urlRequest] autorelease]; AFXMLRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
if (success) { if (success) {
success(operation.request, operation.response, responseObject); success(operation.request, operation.response, responseObject);
@ -71,7 +71,7 @@ static dispatch_queue_t xml_request_operation_processing_queue() {
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure
{ {
AFXMLRequestOperation *requestOperation = [[[self alloc] initWithRequest:urlRequest] autorelease]; AFXMLRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, __unused id responseObject) { [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, __unused id responseObject) {
if (success) { if (success) {
NSXMLDocument *XMLDocument = [(AFXMLRequestOperation *)operation responseXMLDocument]; NSXMLDocument *XMLDocument = [(AFXMLRequestOperation *)operation responseXMLDocument];
@ -88,21 +88,10 @@ static dispatch_queue_t xml_request_operation_processing_queue() {
} }
#endif #endif
- (void)dealloc {
[_responseXMLParser release];
#if __MAC_OS_X_VERSION_MIN_REQUIRED
[_responseXMLDocument release];
#endif
[_XMLError release];
[super dealloc];
}
- (NSXMLParser *)responseXMLParser { - (NSXMLParser *)responseXMLParser {
if (!_responseXMLParser && [self.responseData length] > 0 && [self isFinished]) { if (!_responseXMLParser && [self.responseData length] > 0 && [self isFinished]) {
self.responseXMLParser = [[[NSXMLParser alloc] initWithData:self.responseData] autorelease]; self.responseXMLParser = [[NSXMLParser alloc] initWithData:self.responseData];
} }
return _responseXMLParser; return _responseXMLParser;
@ -112,7 +101,7 @@ static dispatch_queue_t xml_request_operation_processing_queue() {
- (NSXMLDocument *)responseXMLDocument { - (NSXMLDocument *)responseXMLDocument {
if (!_responseXMLDocument && [self.responseData length] > 0 && [self isFinished]) { if (!_responseXMLDocument && [self.responseData length] > 0 && [self isFinished]) {
NSError *error = nil; NSError *error = nil;
self.responseXMLDocument = [[[NSXMLDocument alloc] initWithData:self.responseData options:0 error:&error] autorelease]; self.responseXMLDocument = [[NSXMLDocument alloc] initWithData:self.responseData options:0 error:&error];
self.XMLError = error; self.XMLError = error;
} }
@ -149,6 +138,8 @@ static dispatch_queue_t xml_request_operation_processing_queue() {
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
self.completionBlock = ^ { self.completionBlock = ^ {
if ([self isCancelled]) { if ([self isCancelled]) {
return; return;
@ -172,6 +163,7 @@ static dispatch_queue_t xml_request_operation_processing_queue() {
} }
}); });
}; };
#pragma clang diagnostic pop
} }
@end @end

View file

@ -113,7 +113,7 @@ static char kAFImageRequestOperationObjectKey;
} else { } else {
self.image = placeholderImage; self.image = placeholderImage;
AFImageRequestOperation *requestOperation = [[[AFImageRequestOperation alloc] initWithRequest:urlRequest] autorelease]; AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) { if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) {
self.image = responseObject; self.image = responseObject;

14
CHANGES
View file

@ -1,3 +1,17 @@
= 1.0RC2 / 2012-06-26
* AFNetworking now requires iOS 5 / Mac OSX 10.7 or higher (Mattt Thompson)
* AFNetworking now uses Automatic Reference Counting (ARC) (Mattt Thompson)
* Revert implementation of `AFHTTPRequestOperation`
`+addAcceptableStatusCodes:` and `+addAcceptableContentTypes:` to use
`class_replaceMethod` with `imp_implementationWithBlock`. (Mattt Thompson)
* Update `AFHTTPClient` to not handle cookies by default (@phamsonha, Mattt Thompson)
* Update icons for iOS example application (Mattt Thompson)
= 0.10.0 / 2012-06-26 = 0.10.0 / 2012-06-26
* Add Twitter Mac Example application (Mattt Thompson) * Add Twitter Mac Example application (Mattt Thompson)

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>

View file

@ -11,19 +11,16 @@
F8129C321591073C009BFE23 /* AFTwitterAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C251591073C009BFE23 /* AFTwitterAPIClient.m */; }; F8129C321591073C009BFE23 /* AFTwitterAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C251591073C009BFE23 /* AFTwitterAPIClient.m */; };
F8129C341591073C009BFE23 /* Tweet.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C2B1591073C009BFE23 /* Tweet.m */; }; F8129C341591073C009BFE23 /* Tweet.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C2B1591073C009BFE23 /* Tweet.m */; };
F8129C351591073C009BFE23 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C2D1591073C009BFE23 /* User.m */; }; F8129C351591073C009BFE23 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C2D1591073C009BFE23 /* User.m */; };
F8129C631591090B009BFE23 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C4F1591090B009BFE23 /* AFHTTPClient.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8129C641591090B009BFE23 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C511591090B009BFE23 /* AFHTTPRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8129C651591090B009BFE23 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C531591090B009BFE23 /* AFImageRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8129C661591090B009BFE23 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C551591090B009BFE23 /* AFJSONRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8129C671591090B009BFE23 /* AFJSONUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C571591090B009BFE23 /* AFJSONUtilities.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8129C681591090B009BFE23 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C591591090B009BFE23 /* AFNetworkActivityIndicatorManager.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8129C691591090B009BFE23 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C5C1591090B009BFE23 /* AFPropertyListRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8129C6A1591090B009BFE23 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C5E1591090B009BFE23 /* AFURLConnectionOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8129C6B1591090B009BFE23 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C601591090B009BFE23 /* AFXMLRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8129C6C1591090B009BFE23 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C621591090B009BFE23 /* UIImageView+AFNetworking.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8129C6F15910B15009BFE23 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C6E15910B15009BFE23 /* main.m */; }; F8129C6F15910B15009BFE23 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C6E15910B15009BFE23 /* main.m */; };
F8129C7115910B3E009BFE23 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F8129C7015910B3E009BFE23 /* MainMenu.xib */; }; F8129C7115910B3E009BFE23 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F8129C7015910B3E009BFE23 /* MainMenu.xib */; };
F8129C7715910C40009BFE23 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C7515910C40009BFE23 /* AppDelegate.m */; }; F8129C7715910C40009BFE23 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C7515910C40009BFE23 /* AppDelegate.m */; };
F82EB07C159A172000B10B56 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F82EB06E159A172000B10B56 /* AFHTTPClient.m */; };
F82EB07D159A172000B10B56 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F82EB070159A172000B10B56 /* AFHTTPRequestOperation.m */; };
F82EB07E159A172000B10B56 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F82EB072159A172000B10B56 /* AFImageRequestOperation.m */; };
F82EB07F159A172000B10B56 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F82EB074159A172000B10B56 /* AFJSONRequestOperation.m */; };
F82EB080159A172000B10B56 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F82EB077159A172000B10B56 /* AFPropertyListRequestOperation.m */; };
F82EB081159A172000B10B56 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F82EB079159A172000B10B56 /* AFURLConnectionOperation.m */; };
F82EB082159A172000B10B56 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F82EB07B159A172000B10B56 /* AFXMLRequestOperation.m */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -38,31 +35,26 @@
F8129C2C1591073C009BFE23 /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = "<group>"; }; F8129C2C1591073C009BFE23 /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = "<group>"; };
F8129C2D1591073C009BFE23 /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = User.m; sourceTree = "<group>"; }; F8129C2D1591073C009BFE23 /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = User.m; sourceTree = "<group>"; };
F8129C311591073C009BFE23 /* AFTwitterAPIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFTwitterAPIClient.h; path = Classes/AFTwitterAPIClient.h; sourceTree = SOURCE_ROOT; }; F8129C311591073C009BFE23 /* AFTwitterAPIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFTwitterAPIClient.h; path = Classes/AFTwitterAPIClient.h; sourceTree = SOURCE_ROOT; };
F8129C4E1591090B009BFE23 /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFHTTPClient.h; path = ../AFNetworking/AFHTTPClient.h; sourceTree = "<group>"; };
F8129C4F1591090B009BFE23 /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFHTTPClient.m; path = ../AFNetworking/AFHTTPClient.m; sourceTree = "<group>"; };
F8129C501591090B009BFE23 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFHTTPRequestOperation.h; path = ../AFNetworking/AFHTTPRequestOperation.h; sourceTree = "<group>"; };
F8129C511591090B009BFE23 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFHTTPRequestOperation.m; path = ../AFNetworking/AFHTTPRequestOperation.m; sourceTree = "<group>"; };
F8129C521591090B009BFE23 /* AFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFImageRequestOperation.h; path = ../AFNetworking/AFImageRequestOperation.h; sourceTree = "<group>"; };
F8129C531591090B009BFE23 /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFImageRequestOperation.m; path = ../AFNetworking/AFImageRequestOperation.m; sourceTree = "<group>"; };
F8129C541591090B009BFE23 /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFJSONRequestOperation.h; path = ../AFNetworking/AFJSONRequestOperation.h; sourceTree = "<group>"; };
F8129C551591090B009BFE23 /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFJSONRequestOperation.m; path = ../AFNetworking/AFJSONRequestOperation.m; sourceTree = "<group>"; };
F8129C561591090B009BFE23 /* AFJSONUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFJSONUtilities.h; path = ../AFNetworking/AFJSONUtilities.h; sourceTree = "<group>"; };
F8129C571591090B009BFE23 /* AFJSONUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFJSONUtilities.m; path = ../AFNetworking/AFJSONUtilities.m; sourceTree = "<group>"; };
F8129C581591090B009BFE23 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFNetworkActivityIndicatorManager.h; path = ../AFNetworking/AFNetworkActivityIndicatorManager.h; sourceTree = "<group>"; };
F8129C591591090B009BFE23 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFNetworkActivityIndicatorManager.m; path = ../AFNetworking/AFNetworkActivityIndicatorManager.m; sourceTree = "<group>"; };
F8129C5A1591090B009BFE23 /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFNetworking.h; path = ../AFNetworking/AFNetworking.h; sourceTree = "<group>"; };
F8129C5B1591090B009BFE23 /* AFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFPropertyListRequestOperation.h; path = ../AFNetworking/AFPropertyListRequestOperation.h; sourceTree = "<group>"; };
F8129C5C1591090B009BFE23 /* AFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFPropertyListRequestOperation.m; path = ../AFNetworking/AFPropertyListRequestOperation.m; sourceTree = "<group>"; };
F8129C5D1591090B009BFE23 /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFURLConnectionOperation.h; path = ../AFNetworking/AFURLConnectionOperation.h; sourceTree = "<group>"; };
F8129C5E1591090B009BFE23 /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFURLConnectionOperation.m; path = ../AFNetworking/AFURLConnectionOperation.m; sourceTree = "<group>"; };
F8129C5F1591090B009BFE23 /* AFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFXMLRequestOperation.h; path = ../AFNetworking/AFXMLRequestOperation.h; sourceTree = "<group>"; };
F8129C601591090B009BFE23 /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFXMLRequestOperation.m; path = ../AFNetworking/AFXMLRequestOperation.m; sourceTree = "<group>"; };
F8129C611591090B009BFE23 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImageView+AFNetworking.h"; path = "../AFNetworking/UIImageView+AFNetworking.h"; sourceTree = "<group>"; };
F8129C621591090B009BFE23 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+AFNetworking.m"; path = "../AFNetworking/UIImageView+AFNetworking.m"; sourceTree = "<group>"; };
F8129C6E15910B15009BFE23 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; }; F8129C6E15910B15009BFE23 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; };
F8129C7015910B3E009BFE23 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = SOURCE_ROOT; }; F8129C7015910B3E009BFE23 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = SOURCE_ROOT; };
F8129C7515910C40009BFE23 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; }; F8129C7515910C40009BFE23 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; };
F8129C7615910C40009BFE23 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; }; F8129C7615910C40009BFE23 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; };
F82EB06D159A172000B10B56 /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFHTTPClient.h; path = ../AFNetworking/AFHTTPClient.h; sourceTree = "<group>"; };
F82EB06E159A172000B10B56 /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFHTTPClient.m; path = ../AFNetworking/AFHTTPClient.m; sourceTree = "<group>"; };
F82EB06F159A172000B10B56 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFHTTPRequestOperation.h; path = ../AFNetworking/AFHTTPRequestOperation.h; sourceTree = "<group>"; };
F82EB070159A172000B10B56 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFHTTPRequestOperation.m; path = ../AFNetworking/AFHTTPRequestOperation.m; sourceTree = "<group>"; };
F82EB071159A172000B10B56 /* AFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFImageRequestOperation.h; path = ../AFNetworking/AFImageRequestOperation.h; sourceTree = "<group>"; };
F82EB072159A172000B10B56 /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFImageRequestOperation.m; path = ../AFNetworking/AFImageRequestOperation.m; sourceTree = "<group>"; };
F82EB073159A172000B10B56 /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFJSONRequestOperation.h; path = ../AFNetworking/AFJSONRequestOperation.h; sourceTree = "<group>"; };
F82EB074159A172000B10B56 /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFJSONRequestOperation.m; path = ../AFNetworking/AFJSONRequestOperation.m; sourceTree = "<group>"; };
F82EB075159A172000B10B56 /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFNetworking.h; path = ../AFNetworking/AFNetworking.h; sourceTree = "<group>"; };
F82EB076159A172000B10B56 /* AFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFPropertyListRequestOperation.h; path = ../AFNetworking/AFPropertyListRequestOperation.h; sourceTree = "<group>"; };
F82EB077159A172000B10B56 /* AFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFPropertyListRequestOperation.m; path = ../AFNetworking/AFPropertyListRequestOperation.m; sourceTree = "<group>"; };
F82EB078159A172000B10B56 /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFURLConnectionOperation.h; path = ../AFNetworking/AFURLConnectionOperation.h; sourceTree = "<group>"; };
F82EB079159A172000B10B56 /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFURLConnectionOperation.m; path = ../AFNetworking/AFURLConnectionOperation.m; sourceTree = "<group>"; };
F82EB07A159A172000B10B56 /* AFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFXMLRequestOperation.h; path = ../AFNetworking/AFXMLRequestOperation.h; sourceTree = "<group>"; };
F82EB07B159A172000B10B56 /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFXMLRequestOperation.m; path = ../AFNetworking/AFXMLRequestOperation.m; sourceTree = "<group>"; };
F877018B159A1CE700B45C0D /* AFNetworking Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "AFNetworking Example.entitlements"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -80,6 +72,7 @@
F8129BF01591061B009BFE23 = { F8129BF01591061B009BFE23 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
F877018B159A1CE700B45C0D /* AFNetworking Example.entitlements */,
F8129C051591061B009BFE23 /* Classes */, F8129C051591061B009BFE23 /* Classes */,
F8129C4C15910901009BFE23 /* Vendor */, F8129C4C15910901009BFE23 /* Vendor */,
F8129BFE1591061B009BFE23 /* Frameworks */, F8129BFE1591061B009BFE23 /* Frameworks */,
@ -152,31 +145,33 @@
F8129C4C15910901009BFE23 /* Vendor */ = { F8129C4C15910901009BFE23 /* Vendor */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
F8129C4E1591090B009BFE23 /* AFHTTPClient.h */, F82EB083159A172500B10B56 /* AFNetworking */,
F8129C4F1591090B009BFE23 /* AFHTTPClient.m */,
F8129C501591090B009BFE23 /* AFHTTPRequestOperation.h */,
F8129C511591090B009BFE23 /* AFHTTPRequestOperation.m */,
F8129C521591090B009BFE23 /* AFImageRequestOperation.h */,
F8129C531591090B009BFE23 /* AFImageRequestOperation.m */,
F8129C541591090B009BFE23 /* AFJSONRequestOperation.h */,
F8129C551591090B009BFE23 /* AFJSONRequestOperation.m */,
F8129C561591090B009BFE23 /* AFJSONUtilities.h */,
F8129C571591090B009BFE23 /* AFJSONUtilities.m */,
F8129C581591090B009BFE23 /* AFNetworkActivityIndicatorManager.h */,
F8129C591591090B009BFE23 /* AFNetworkActivityIndicatorManager.m */,
F8129C5A1591090B009BFE23 /* AFNetworking.h */,
F8129C5B1591090B009BFE23 /* AFPropertyListRequestOperation.h */,
F8129C5C1591090B009BFE23 /* AFPropertyListRequestOperation.m */,
F8129C5D1591090B009BFE23 /* AFURLConnectionOperation.h */,
F8129C5E1591090B009BFE23 /* AFURLConnectionOperation.m */,
F8129C5F1591090B009BFE23 /* AFXMLRequestOperation.h */,
F8129C601591090B009BFE23 /* AFXMLRequestOperation.m */,
F8129C611591090B009BFE23 /* UIImageView+AFNetworking.h */,
F8129C621591090B009BFE23 /* UIImageView+AFNetworking.m */,
); );
name = Vendor; name = Vendor;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
F82EB083159A172500B10B56 /* AFNetworking */ = {
isa = PBXGroup;
children = (
F82EB075159A172000B10B56 /* AFNetworking.h */,
F82EB078159A172000B10B56 /* AFURLConnectionOperation.h */,
F82EB079159A172000B10B56 /* AFURLConnectionOperation.m */,
F82EB06F159A172000B10B56 /* AFHTTPRequestOperation.h */,
F82EB070159A172000B10B56 /* AFHTTPRequestOperation.m */,
F82EB073159A172000B10B56 /* AFJSONRequestOperation.h */,
F82EB074159A172000B10B56 /* AFJSONRequestOperation.m */,
F82EB07A159A172000B10B56 /* AFXMLRequestOperation.h */,
F82EB07B159A172000B10B56 /* AFXMLRequestOperation.m */,
F82EB076159A172000B10B56 /* AFPropertyListRequestOperation.h */,
F82EB077159A172000B10B56 /* AFPropertyListRequestOperation.m */,
F82EB06D159A172000B10B56 /* AFHTTPClient.h */,
F82EB06E159A172000B10B56 /* AFHTTPClient.m */,
F82EB071159A172000B10B56 /* AFImageRequestOperation.h */,
F82EB072159A172000B10B56 /* AFImageRequestOperation.m */,
);
name = AFNetworking;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
@ -241,18 +236,15 @@
F8129C341591073C009BFE23 /* Tweet.m in Sources */, F8129C341591073C009BFE23 /* Tweet.m in Sources */,
F8129C351591073C009BFE23 /* User.m in Sources */, F8129C351591073C009BFE23 /* User.m in Sources */,
F8129C321591073C009BFE23 /* AFTwitterAPIClient.m in Sources */, F8129C321591073C009BFE23 /* AFTwitterAPIClient.m in Sources */,
F8129C631591090B009BFE23 /* AFHTTPClient.m in Sources */,
F8129C641591090B009BFE23 /* AFHTTPRequestOperation.m in Sources */,
F8129C651591090B009BFE23 /* AFImageRequestOperation.m in Sources */,
F8129C661591090B009BFE23 /* AFJSONRequestOperation.m in Sources */,
F8129C671591090B009BFE23 /* AFJSONUtilities.m in Sources */,
F8129C681591090B009BFE23 /* AFNetworkActivityIndicatorManager.m in Sources */,
F8129C691591090B009BFE23 /* AFPropertyListRequestOperation.m in Sources */,
F8129C6A1591090B009BFE23 /* AFURLConnectionOperation.m in Sources */,
F8129C6B1591090B009BFE23 /* AFXMLRequestOperation.m in Sources */,
F8129C6C1591090B009BFE23 /* UIImageView+AFNetworking.m in Sources */,
F8129C6F15910B15009BFE23 /* main.m in Sources */, F8129C6F15910B15009BFE23 /* main.m in Sources */,
F8129C7715910C40009BFE23 /* AppDelegate.m in Sources */, F8129C7715910C40009BFE23 /* AppDelegate.m in Sources */,
F82EB07C159A172000B10B56 /* AFHTTPClient.m in Sources */,
F82EB07D159A172000B10B56 /* AFHTTPRequestOperation.m in Sources */,
F82EB07E159A172000B10B56 /* AFImageRequestOperation.m in Sources */,
F82EB07F159A172000B10B56 /* AFJSONRequestOperation.m in Sources */,
F82EB080159A172000B10B56 /* AFPropertyListRequestOperation.m in Sources */,
F82EB081159A172000B10B56 /* AFURLConnectionOperation.m in Sources */,
F82EB082159A172000B10B56 /* AFXMLRequestOperation.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -309,6 +301,8 @@
F8129C1A1591061B009BFE23 /* Debug */ = { F8129C1A1591061B009BFE23 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_ENTITLEMENTS = "AFNetworking Example.entitlements";
CODE_SIGN_IDENTITY = "Mac Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Prefix.pch; GCC_PREFIX_HEADER = Prefix.pch;
INFOPLIST_FILE = "Mac-Info.plist"; INFOPLIST_FILE = "Mac-Info.plist";
@ -320,6 +314,8 @@
F8129C1B1591061B009BFE23 /* Release */ = { F8129C1B1591061B009BFE23 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_ENTITLEMENTS = "AFNetworking Example.entitlements";
CODE_SIGN_IDENTITY = "Mac Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Prefix.pch; GCC_PREFIX_HEADER = Prefix.pch;
INFOPLIST_FILE = "Mac-Info.plist"; INFOPLIST_FILE = "Mac-Info.plist";

View file

@ -23,16 +23,15 @@
F8FA9494150EF97E00ED4EAD /* Tweet.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9493150EF97E00ED4EAD /* Tweet.m */; }; F8FA9494150EF97E00ED4EAD /* Tweet.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9493150EF97E00ED4EAD /* Tweet.m */; };
F8FA9497150EF98800ED4EAD /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9496150EF98800ED4EAD /* User.m */; }; F8FA9497150EF98800ED4EAD /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9496150EF98800ED4EAD /* User.m */; };
F8FA949A150EF9DA00ED4EAD /* PublicTimelineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9499150EF9DA00ED4EAD /* PublicTimelineViewController.m */; }; F8FA949A150EF9DA00ED4EAD /* PublicTimelineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9499150EF9DA00ED4EAD /* PublicTimelineViewController.m */; };
F8FA94B1150EFEC100ED4EAD /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA949D150EFEC100ED4EAD /* AFHTTPClient.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; F8FA94B1150EFEC100ED4EAD /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA949D150EFEC100ED4EAD /* AFHTTPClient.m */; };
F8FA94B2150EFEC100ED4EAD /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; F8FA94B2150EFEC100ED4EAD /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */; };
F8FA94B3150EFEC100ED4EAD /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A1150EFEC100ED4EAD /* AFImageRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; F8FA94B3150EFEC100ED4EAD /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A1150EFEC100ED4EAD /* AFImageRequestOperation.m */; };
F8FA94B4150EFEC100ED4EAD /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A3150EFEC100ED4EAD /* AFJSONRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; F8FA94B4150EFEC100ED4EAD /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A3150EFEC100ED4EAD /* AFJSONRequestOperation.m */; };
F8FA94B5150EFEC100ED4EAD /* AFJSONUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A5150EFEC100ED4EAD /* AFJSONUtilities.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; F8FA94B6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */; };
F8FA94B6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; F8FA94B7150EFEC100ED4EAD /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AA150EFEC100ED4EAD /* AFPropertyListRequestOperation.m */; };
F8FA94B7150EFEC100ED4EAD /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AA150EFEC100ED4EAD /* AFPropertyListRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; F8FA94B8150EFEC100ED4EAD /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */; };
F8FA94B8150EFEC100ED4EAD /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; F8FA94B9150EFEC100ED4EAD /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AE150EFEC100ED4EAD /* AFXMLRequestOperation.m */; };
F8FA94B9150EFEC100ED4EAD /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AE150EFEC100ED4EAD /* AFXMLRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; F8FA94BA150EFEC100ED4EAD /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94B0150EFEC100ED4EAD /* UIImageView+AFNetworking.m */; };
F8FA94BA150EFEC100ED4EAD /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94B0150EFEC100ED4EAD /* UIImageView+AFNetworking.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94C1150F019100ED4EAD /* TweetTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94C0150F019100ED4EAD /* TweetTableViewCell.m */; }; F8FA94C1150F019100ED4EAD /* TweetTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94C0150F019100ED4EAD /* TweetTableViewCell.m */; };
F8FA94D0150F094D00ED4EAD /* profile-image-placeholder.png in Resources */ = {isa = PBXBuildFile; fileRef = F8FA94CC150F094D00ED4EAD /* profile-image-placeholder.png */; }; F8FA94D0150F094D00ED4EAD /* profile-image-placeholder.png in Resources */ = {isa = PBXBuildFile; fileRef = F8FA94CC150F094D00ED4EAD /* profile-image-placeholder.png */; };
F8FA94D1150F094D00ED4EAD /* profile-image-placeholder@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8FA94CD150F094D00ED4EAD /* profile-image-placeholder@2x.png */; }; F8FA94D1150F094D00ED4EAD /* profile-image-placeholder@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8FA94CD150F094D00ED4EAD /* profile-image-placeholder@2x.png */; };
@ -71,8 +70,6 @@
F8FA94A1150EFEC100ED4EAD /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFImageRequestOperation.m; sourceTree = "<group>"; }; F8FA94A1150EFEC100ED4EAD /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFImageRequestOperation.m; sourceTree = "<group>"; };
F8FA94A2150EFEC100ED4EAD /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFJSONRequestOperation.h; sourceTree = "<group>"; }; F8FA94A2150EFEC100ED4EAD /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFJSONRequestOperation.h; sourceTree = "<group>"; };
F8FA94A3150EFEC100ED4EAD /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONRequestOperation.m; sourceTree = "<group>"; }; F8FA94A3150EFEC100ED4EAD /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONRequestOperation.m; sourceTree = "<group>"; };
F8FA94A4150EFEC100ED4EAD /* AFJSONUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFJSONUtilities.h; sourceTree = "<group>"; };
F8FA94A5150EFEC100ED4EAD /* AFJSONUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONUtilities.m; sourceTree = "<group>"; };
F8FA94A6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkActivityIndicatorManager.h; sourceTree = "<group>"; }; F8FA94A6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkActivityIndicatorManager.h; sourceTree = "<group>"; };
F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkActivityIndicatorManager.m; sourceTree = "<group>"; }; F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkActivityIndicatorManager.m; sourceTree = "<group>"; };
F8FA94A8150EFEC100ED4EAD /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = "<group>"; }; F8FA94A8150EFEC100ED4EAD /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = "<group>"; };
@ -249,8 +246,6 @@
F8FA94B0150EFEC100ED4EAD /* UIImageView+AFNetworking.m */, F8FA94B0150EFEC100ED4EAD /* UIImageView+AFNetworking.m */,
F8FA94A6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.h */, F8FA94A6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.h */,
F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */, F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */,
F8FA94A4150EFEC100ED4EAD /* AFJSONUtilities.h */,
F8FA94A5150EFEC100ED4EAD /* AFJSONUtilities.m */,
); );
name = AFNetworking; name = AFNetworking;
path = ../AFNetworking; path = ../AFNetworking;
@ -282,7 +277,7 @@
F8E469571395739C00DB05C8 /* Project object */ = { F8E469571395739C00DB05C8 /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0430; LastUpgradeCheck = 0450;
ORGANIZATIONNAME = Gowalla; ORGANIZATIONNAME = Gowalla;
}; };
buildConfigurationList = F8E4695A1395739C00DB05C8 /* Build configuration list for PBXProject "AFNetworking iOS Example" */; buildConfigurationList = F8E4695A1395739C00DB05C8 /* Build configuration list for PBXProject "AFNetworking iOS Example" */;
@ -332,7 +327,6 @@
F8FA94B2150EFEC100ED4EAD /* AFHTTPRequestOperation.m in Sources */, F8FA94B2150EFEC100ED4EAD /* AFHTTPRequestOperation.m in Sources */,
F8FA94B3150EFEC100ED4EAD /* AFImageRequestOperation.m in Sources */, F8FA94B3150EFEC100ED4EAD /* AFImageRequestOperation.m in Sources */,
F8FA94B4150EFEC100ED4EAD /* AFJSONRequestOperation.m in Sources */, F8FA94B4150EFEC100ED4EAD /* AFJSONRequestOperation.m in Sources */,
F8FA94B5150EFEC100ED4EAD /* AFJSONUtilities.m in Sources */,
F8FA94B6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m in Sources */, F8FA94B6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m in Sources */,
F8FA94B7150EFEC100ED4EAD /* AFPropertyListRequestOperation.m in Sources */, F8FA94B7150EFEC100ED4EAD /* AFPropertyListRequestOperation.m in Sources */,
F8FA94B8150EFEC100ED4EAD /* AFURLConnectionOperation.m in Sources */, F8FA94B8150EFEC100ED4EAD /* AFURLConnectionOperation.m in Sources */,
@ -392,7 +386,7 @@
GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNUSED_PARAMETER = NO; GCC_WARN_UNUSED_PARAMETER = NO;
INFOPLIST_FILE = "iOS-Info.plist"; INFOPLIST_FILE = "iOS-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0; IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;
}; };
@ -411,7 +405,7 @@
GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNUSED_PARAMETER = NO; GCC_WARN_UNUSED_PARAMETER = NO;
INFOPLIST_FILE = "iOS-Info.plist"; INFOPLIST_FILE = "iOS-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0; IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;

View file

@ -42,7 +42,7 @@
@interface AppDelegate : NSObject <NSApplicationDelegate> @interface AppDelegate : NSObject <NSApplicationDelegate>
@property (strong) IBOutlet NSWindow *window; @property (strong) IBOutlet NSWindow *window;
@property (weak) IBOutlet NSTableView *tableView; @property (strong) IBOutlet NSTableView *tableView;
@property (strong) IBOutlet NSArrayController *tweetsArrayController; @property (strong) IBOutlet NSArrayController *tweetsArrayController;
@end @end

View file

@ -35,7 +35,7 @@
- (BOOL)application:(UIApplication *)application - (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ {
NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 diskCapacity:1024 * 1024 * 5 diskPath:nil]; NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
[NSURLCache setSharedURLCache:URLCache]; [NSURLCache setSharedURLCache:URLCache];
[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
@ -66,7 +66,7 @@ didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
@synthesize tweetsArrayController = _tweetsArrayController; @synthesize tweetsArrayController = _tweetsArrayController;
- (void)applicationDidFinishLaunching:(NSNotification *)notification { - (void)applicationDidFinishLaunching:(NSNotification *)notification {
NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 diskCapacity:1024 * 1024 * 5 diskPath:nil]; NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
[NSURLCache setSharedURLCache:URLCache]; [NSURLCache setSharedURLCache:URLCache];
[self.window makeKeyAndOrderFront:self]; [self.window makeKeyAndOrderFront:self];

View file

@ -26,10 +26,10 @@
@interface Tweet : NSObject @interface Tweet : NSObject
@property (readonly) NSUInteger tweetID; @property (readonly, assign) NSUInteger tweetID;
@property (readonly) NSString *text; @property (readonly, strong) NSString *text;
@property (readonly) User *user; @property (readonly, strong) User *user;
- (id)initWithAttributes:(NSDictionary *)attributes; - (id)initWithAttributes:(NSDictionary *)attributes;

View file

@ -25,13 +25,7 @@
#import "AFTwitterAPIClient.h" #import "AFTwitterAPIClient.h"
@implementation Tweet { @implementation Tweet
@private
NSUInteger _tweetID;
__strong NSString *_text;
__strong User *_user;
}
@synthesize tweetID = _tweetID; @synthesize tweetID = _tweetID;
@synthesize text = _text; @synthesize text = _text;
@synthesize user = _user; @synthesize user = _user;

View file

@ -27,7 +27,7 @@ extern NSString * const kUserProfileImageDidLoadNotification;
@interface User : NSObject @interface User : NSObject
@property (readonly) NSUInteger userID; @property (readonly) NSUInteger userID;
@property (readonly) NSString *username; @property (strong, readonly) NSString *username;
@property (unsafe_unretained, readonly) NSURL *profileImageURL; @property (unsafe_unretained, readonly) NSURL *profileImageURL;
- (id)initWithAttributes:(NSDictionary *)attributes; - (id)initWithAttributes:(NSDictionary *)attributes;

View file

@ -25,11 +25,13 @@
NSString * const kUserProfileImageDidLoadNotification = @"com.alamofire.user.profile-image.loaded"; NSString * const kUserProfileImageDidLoadNotification = @"com.alamofire.user.profile-image.loaded";
#if __MAC_OS_X_VERSION_MIN_REQUIRED
@interface User () @interface User ()
#if __MAC_OS_X_VERSION_MIN_REQUIRED #if __MAC_OS_X_VERSION_MIN_REQUIRED
+ (NSOperationQueue *)sharedProfileImageRequestOperationQueue; + (NSOperationQueue *)sharedProfileImageRequestOperationQueue;
#endif #endif
@end @end
#endif
@implementation User { @implementation User {
@private @private

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View file

@ -41,14 +41,14 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>0.1.0</string> <string>1.0.0</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>UIPrerenderedIcon</key>
<true/>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>
</array> </array>
<key>UIPrerenderedIcon</key>
<true/>
</dict> </dict>
</plist> </plist>

View file

@ -143,20 +143,7 @@ operation.outputStream = [NSOutputStream outputStreamToMemory];
## Requirements ## Requirements
AFNetworking requires either [iOS 4.0](http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS4.html) and above, or [Mac OS 10.6](http://developer.apple.com/library/mac/#releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_6.html#//apple_ref/doc/uid/TP40008898-SW7) ([64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)) and above. AFNetworking requires either [iOS 5.0](http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS4.html) and above, or [Mac OS 10.7](http://developer.apple.com/library/mac/#releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_6.html#//apple_ref/doc/uid/TP40008898-SW7) ([64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)) and above.
AFNetworking uses [`NSJSONSerialization`](http://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html) if it is available. If your app targets a platform where this class is not available you can include one of the following JSON libraries to your project for AFNetworking to automatically detect and use.
* [JSONKit](https://github.com/johnezang/JSONKit)
* [SBJson](https://stig.github.com/json-framework/)
* [YAJL](https://lloyd.github.com/yajl/)
* [NextiveJson](https://github.com/nextive/NextiveJson)
### ARC Support
AFNetworking will transition its codebase to ARC in a future release.
If you are including AFNetworking in a project that uses [Automatic Reference Counting (ARC)](http://clang.llvm.org/docs/AutomaticReferenceCounting.html) enabled, you will need to set the `-fno-objc-arc` compiler flag on all of the AFNetworking source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. Now select all AFNetworking source files, press Enter, insert `-fno-objc-arc` and then "Done" to disable ARC for AFNetworking.
## Credits ## Credits