- Update
No files matched your search
@@ -0,0 +1,13 @@
|
||||
# Xcode
|
||||
build/*
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
profile
|
||||
*.moved-aside
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "OHHTTPStubs/UnitTests/AFNetworking"]
|
||||
path = OHHTTPStubs/UnitTests/AFNetworking
|
||||
url = http://github.com/AFNetworking/AFNetworking.git
|
||||
@@ -0,0 +1,29 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
***********************************************************************************
|
||||
*
|
||||
* Any comment or suggestion welcome. Referencing this project in your AboutBox is appreciated.
|
||||
* Please tell me if you use this class so we can cross-reference our projects.
|
||||
*
|
||||
***********************************************************************************/
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
***********************************************************************************/
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Imports
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "OHHTTPStubsResponse.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Types
|
||||
|
||||
typedef OHHTTPStubsResponse*(^OHHTTPStubsRequestHandler)(NSURLRequest* request, BOOL onlyCheck);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Interface
|
||||
|
||||
@interface OHHTTPStubs : NSObject
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Singleton methods
|
||||
|
||||
+ (OHHTTPStubs*)sharedInstance;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Class Methods
|
||||
|
||||
//! Commmodity method: calls instance method on sharedInstance directly
|
||||
|
||||
// same as addRequestHandler but process the checking and the building of the actual stub in separate blocks for performance
|
||||
+(id)shouldStubRequestsPassingTest:(BOOL(^)(NSURLRequest* request))shouldReturnStubForRequest
|
||||
withStubResponse:(OHHTTPStubsResponse*(^)(NSURLRequest* request))handler;
|
||||
|
||||
+(id)addRequestHandler:(OHHTTPStubsRequestHandler)handler;
|
||||
+(BOOL)removeRequestHandler:(id)handler;
|
||||
+(void)removeLastRequestHandler;
|
||||
+(void)removeAllRequestHandlers;
|
||||
+(void)setEnabled:(BOOL)enabled;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Instance Methods
|
||||
|
||||
-(id)addRequestHandler:(OHHTTPStubsRequestHandler)handler;
|
||||
-(BOOL)removeRequestHandler:(id)handler;
|
||||
-(void)removeLastRequestHandler;
|
||||
-(void)removeAllRequestHandlers;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,302 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
***********************************************************************************/
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Imports
|
||||
|
||||
#import "OHHTTPStubs.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Types
|
||||
|
||||
@interface OHHTTPStubsProtocol : NSURLProtocol @end
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Private Interface
|
||||
|
||||
@interface OHHTTPStubs()
|
||||
@property(nonatomic, retain) NSMutableArray* requestHandlers;
|
||||
@end
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Implementation
|
||||
|
||||
@implementation OHHTTPStubs
|
||||
@synthesize requestHandlers = _requestHandlers;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Singleton methods
|
||||
|
||||
+ (OHHTTPStubs*)sharedInstance
|
||||
{
|
||||
static OHHTTPStubs *sharedInstance = nil;
|
||||
|
||||
static dispatch_once_t predicate;
|
||||
dispatch_once(&predicate, ^{
|
||||
sharedInstance = [[self alloc] init];
|
||||
});
|
||||
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Setup & Teardown
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
self.requestHandlers = [NSMutableArray array];
|
||||
[[self class] setEnabled:YES];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[self class] setEnabled:NO];
|
||||
self.requestHandlers = nil;
|
||||
#if ! __has_feature(objc_arc)
|
||||
[super dealloc];
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Public class methods
|
||||
|
||||
// Commodity methods
|
||||
+(id)shouldStubRequestsPassingTest:(BOOL(^)(NSURLRequest* request))shouldReturnStubForRequest
|
||||
withStubResponse:(OHHTTPStubsResponse*(^)(NSURLRequest* request))requestHandler
|
||||
{
|
||||
return [self addRequestHandler:^OHHTTPStubsResponse *(NSURLRequest *request, BOOL onlyCheck)
|
||||
{
|
||||
BOOL shouldStub = shouldReturnStubForRequest ? shouldReturnStubForRequest(request) : YES;
|
||||
if (onlyCheck)
|
||||
{
|
||||
return shouldStub ? OHHTTPStubsResponseUseStub : OHHTTPStubsResponseDontUseStub;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (requestHandler && shouldStub) ? requestHandler(request) : nil;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
+(id)addRequestHandler:(OHHTTPStubsRequestHandler)handler
|
||||
{
|
||||
return [[self sharedInstance] addRequestHandler:handler];
|
||||
}
|
||||
+(BOOL)removeRequestHandler:(id)handler
|
||||
{
|
||||
return [[self sharedInstance] removeRequestHandler:handler];
|
||||
}
|
||||
+(void)removeLastRequestHandler
|
||||
{
|
||||
[[self sharedInstance] removeLastRequestHandler];
|
||||
}
|
||||
+(void)removeAllRequestHandlers
|
||||
{
|
||||
[[self sharedInstance] removeAllRequestHandlers];
|
||||
}
|
||||
|
||||
+(void)setEnabled:(BOOL)enabled
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
[NSURLProtocol registerClass:[OHHTTPStubsProtocol class]];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Force instanciate sharedInstance to avoid it being created later and this turning setEnabled to YES again
|
||||
(void)[self sharedInstance]; // This way if we call [setEnabled:NO] before any call to sharedInstance it will be kept disabled
|
||||
[NSURLProtocol unregisterClass:[OHHTTPStubsProtocol class]];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Public instance methods
|
||||
|
||||
-(id)addRequestHandler:(OHHTTPStubsRequestHandler)handler
|
||||
{
|
||||
OHHTTPStubsRequestHandler handlerCopy = [handler copy];
|
||||
[self.requestHandlers addObject:handlerCopy];
|
||||
#if ! __has_feature(objc_arc)
|
||||
[handlerCopy autorelease];
|
||||
#endif
|
||||
return handlerCopy;
|
||||
}
|
||||
|
||||
-(BOOL)removeRequestHandler:(id)handler
|
||||
{
|
||||
BOOL handlerFound = [self.requestHandlers containsObject:handler];
|
||||
[self.requestHandlers removeObject:handler];
|
||||
return handlerFound;
|
||||
}
|
||||
-(void)removeLastRequestHandler
|
||||
{
|
||||
[self.requestHandlers removeLastObject];
|
||||
}
|
||||
|
||||
-(void)removeAllRequestHandlers
|
||||
{
|
||||
[self.requestHandlers removeAllObjects];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Private Protocol Class
|
||||
|
||||
// Undocumented initializer obtained by class-dump
|
||||
// Don't use this in production code destined for the App Store
|
||||
#if ! DEBUG
|
||||
#warning This code uses a private method: use only for you app testing. Don't use OHHTTPStubs when publishing your app on the App Store.
|
||||
#endif
|
||||
|
||||
@interface NSHTTPURLResponse(UndocumentedInitializer)
|
||||
- (id)initWithURL:(NSURL*)URL
|
||||
statusCode:(NSInteger)statusCode
|
||||
headerFields:(NSDictionary*)headerFields
|
||||
requestTime:(double)requestTime;
|
||||
@end
|
||||
|
||||
@implementation OHHTTPStubsProtocol
|
||||
|
||||
+ (BOOL)canInitWithRequest:(NSURLRequest *)request
|
||||
{
|
||||
NSArray* requestHandlers = [OHHTTPStubs sharedInstance].requestHandlers;
|
||||
id response = nil;
|
||||
for(OHHTTPStubsRequestHandler handler in [requestHandlers reverseObjectEnumerator])
|
||||
{
|
||||
response = handler(request, YES);
|
||||
if (response) break;
|
||||
}
|
||||
return (response != nil);
|
||||
}
|
||||
|
||||
+ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request
|
||||
{
|
||||
return request;
|
||||
}
|
||||
|
||||
- (NSCachedURLResponse *)cachedResponse
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)startLoading
|
||||
{
|
||||
NSURLRequest* request = [self request];
|
||||
id<NSURLProtocolClient> client = [self client];
|
||||
|
||||
OHHTTPStubsResponse* responseStub = nil;
|
||||
NSArray* requestHandlers = [OHHTTPStubs sharedInstance].requestHandlers;
|
||||
for(OHHTTPStubsRequestHandler handler in [requestHandlers reverseObjectEnumerator])
|
||||
{
|
||||
responseStub = handler(request, NO);
|
||||
if (responseStub) break;
|
||||
}
|
||||
|
||||
if (responseStub.error == nil)
|
||||
{
|
||||
// Send the fake data
|
||||
|
||||
NSTimeInterval canonicalResponseTime = responseStub.responseTime;
|
||||
if (canonicalResponseTime<0)
|
||||
{
|
||||
// Interpret it as a bandwidth in KB/s ( -2 => 2KB/s )
|
||||
double bandwidth = -canonicalResponseTime * 1000.0; // in bytes per second
|
||||
canonicalResponseTime = responseStub.responseData.length / bandwidth;
|
||||
}
|
||||
NSTimeInterval requestTime = canonicalResponseTime * 0.1;
|
||||
NSTimeInterval responseTime = canonicalResponseTime - requestTime;
|
||||
|
||||
NSHTTPURLResponse* urlResponse = [[NSHTTPURLResponse alloc] initWithURL:request.URL
|
||||
statusCode:responseStub.statusCode
|
||||
headerFields:responseStub.httpHeaders
|
||||
requestTime:requestTime];
|
||||
|
||||
// Cookies handling
|
||||
if (request.HTTPShouldHandleCookies)
|
||||
{
|
||||
NSArray* cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:responseStub.httpHeaders forURL:request.URL];
|
||||
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:cookies forURL:request.URL mainDocumentURL:request.mainDocumentURL];
|
||||
}
|
||||
|
||||
execute_after(requestTime,^{
|
||||
[client URLProtocol:self didReceiveResponse:urlResponse cacheStoragePolicy:NSURLCacheStorageNotAllowed];
|
||||
|
||||
execute_after(responseTime,^{
|
||||
[client URLProtocol:self didLoadData:responseStub.responseData];
|
||||
[client URLProtocolDidFinishLoading:self];
|
||||
});
|
||||
});
|
||||
#if ! __has_feature(objc_arc)
|
||||
[urlResponse autorelease];
|
||||
#endif
|
||||
} else {
|
||||
// Send the canned error
|
||||
execute_after(responseStub.responseTime, ^{
|
||||
[client URLProtocol:self didFailWithError:responseStub.error];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopLoading
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Delayed execution utility methods
|
||||
/////////////////////////////////////////////
|
||||
|
||||
//! execute the block on the current NSRunLoop after a given amount of seconds
|
||||
void execute_after(NSTimeInterval delayInSeconds, dispatch_block_t block)
|
||||
{
|
||||
/* We know that -[NSURLProtocol startLoading] is called on a dedicated thread that has a runloop, so that there is no problem firing a timer here
|
||||
@note We use the '-invoke' method (private API) because it is handy and OHHTTPStubs will never be used in production code anyway
|
||||
*/
|
||||
dispatch_block_t blockCopy = [block copy];
|
||||
[NSTimer scheduledTimerWithTimeInterval:delayInSeconds target:blockCopy selector:@selector(invoke) userInfo:nil repeats:NO];
|
||||
#if ! __has_feature(objc_arc)
|
||||
[blockCopy autorelease];
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,423 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
09739F2C16900E81009851EF /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 09739F2B16900E81009851EF /* AFNetworkingTests.m */; };
|
||||
0979357D161B6251006DB5D5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0979357C161B6251006DB5D5 /* Foundation.framework */; };
|
||||
0979359B161B62C0006DB5D5 /* OHHTTPStubs.m in Sources */ = {isa = PBXBuildFile; fileRef = 09793598161B62C0006DB5D5 /* OHHTTPStubs.m */; };
|
||||
0979359C161B62C0006DB5D5 /* OHHTTPStubsResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 0979359A161B62C0006DB5D5 /* OHHTTPStubsResponse.m */; };
|
||||
0979359E161B62EF006DB5D5 /* OHHTTPStubs.h in Headers */ = {isa = PBXBuildFile; fileRef = 09793597161B62C0006DB5D5 /* OHHTTPStubs.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0979359F161B62EF006DB5D5 /* OHHTTPStubsResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 09793599161B62C0006DB5D5 /* OHHTTPStubsResponse.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
098368D0168FC7920082B1A4 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 098368CF168FC7920082B1A4 /* SenTestingKit.framework */; };
|
||||
098368D3168FC7920082B1A4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0979357C161B6251006DB5D5 /* Foundation.framework */; };
|
||||
098368DC168FC7920082B1A4 /* AsyncSenTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 098368DB168FC7920082B1A4 /* AsyncSenTestCase.m */; };
|
||||
098368E4168FD0E50082B1A4 /* NSURLConnectionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 098368E3168FD0E50082B1A4 /* NSURLConnectionTests.m */; };
|
||||
098368E8168FE49A0082B1A4 /* libOHHTTPStubs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 09793579161B6251006DB5D5 /* libOHHTTPStubs.a */; };
|
||||
098368EA168FF9740082B1A4 /* NSURLConnectionDelegateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 098368E9168FF9740082B1A4 /* NSURLConnectionDelegateTests.m */; };
|
||||
098368EC169000340082B1A4 /* WithContentsOfURLTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 098368EB169000340082B1A4 /* WithContentsOfURLTests.m */; };
|
||||
099C73541690397600239880 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 099C73501690397600239880 /* AFHTTPRequestOperation.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
|
||||
099C73551690397600239880 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 099C73531690397600239880 /* AFURLConnectionOperation.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
|
||||
099C735716903B9800239880 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 099C735616903B9800239880 /* UIKit.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
09739F2B16900E81009851EF /* AFNetworkingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkingTests.m; sourceTree = "<group>"; };
|
||||
09793579161B6251006DB5D5 /* libOHHTTPStubs.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOHHTTPStubs.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
0979357C161B6251006DB5D5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
09793597161B62C0006DB5D5 /* OHHTTPStubs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OHHTTPStubs.h; sourceTree = "<group>"; };
|
||||
09793598161B62C0006DB5D5 /* OHHTTPStubs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OHHTTPStubs.m; sourceTree = "<group>"; };
|
||||
09793599161B62C0006DB5D5 /* OHHTTPStubsResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OHHTTPStubsResponse.h; sourceTree = "<group>"; };
|
||||
0979359A161B62C0006DB5D5 /* OHHTTPStubsResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OHHTTPStubsResponse.m; sourceTree = "<group>"; };
|
||||
097935A0161B644E006DB5D5 /* PortableLibrary.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = PortableLibrary.xcconfig; sourceTree = "<group>"; };
|
||||
098368CE168FC7920082B1A4 /* UnitTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
098368CF168FC7920082B1A4 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
|
||||
098368D6168FC7920082B1A4 /* UnitTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UnitTests-Info.plist"; sourceTree = "<group>"; };
|
||||
098368DA168FC7920082B1A4 /* AsyncSenTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AsyncSenTestCase.h; sourceTree = "<group>"; };
|
||||
098368DB168FC7920082B1A4 /* AsyncSenTestCase.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AsyncSenTestCase.m; sourceTree = "<group>"; };
|
||||
098368DD168FC7920082B1A4 /* UnitTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UnitTests-Prefix.pch"; sourceTree = "<group>"; };
|
||||
098368E3168FD0E50082B1A4 /* NSURLConnectionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSURLConnectionTests.m; sourceTree = "<group>"; };
|
||||
098368E9168FF9740082B1A4 /* NSURLConnectionDelegateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSURLConnectionDelegateTests.m; sourceTree = "<group>"; };
|
||||
098368EB169000340082B1A4 /* WithContentsOfURLTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WithContentsOfURLTests.m; sourceTree = "<group>"; };
|
||||
099C734F1690397600239880 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = "<group>"; };
|
||||
099C73501690397600239880 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = "<group>"; };
|
||||
099C73521690397600239880 /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLConnectionOperation.h; sourceTree = "<group>"; };
|
||||
099C73531690397600239880 /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLConnectionOperation.m; sourceTree = "<group>"; };
|
||||
099C735616903B9800239880 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
09793576161B6251006DB5D5 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0979357D161B6251006DB5D5 /* Foundation.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
098368CA168FC7920082B1A4 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
099C735716903B9800239880 /* UIKit.framework in Frameworks */,
|
||||
098368E8168FE49A0082B1A4 /* libOHHTTPStubs.a in Frameworks */,
|
||||
098368D0168FC7920082B1A4 /* SenTestingKit.framework in Frameworks */,
|
||||
098368D3168FC7920082B1A4 /* Foundation.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
0979356E161B6251006DB5D5 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
097935A0161B644E006DB5D5 /* PortableLibrary.xcconfig */,
|
||||
0979357E161B6251006DB5D5 /* OHHTTPStubs */,
|
||||
098368D4168FC7920082B1A4 /* UnitTests */,
|
||||
0979357B161B6251006DB5D5 /* Frameworks */,
|
||||
0979357A161B6251006DB5D5 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0979357A161B6251006DB5D5 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
09793579161B6251006DB5D5 /* libOHHTTPStubs.a */,
|
||||
098368CE168FC7920082B1A4 /* UnitTests.octest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0979357B161B6251006DB5D5 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0979357C161B6251006DB5D5 /* Foundation.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0979357E161B6251006DB5D5 /* OHHTTPStubs */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
09793597161B62C0006DB5D5 /* OHHTTPStubs.h */,
|
||||
09793598161B62C0006DB5D5 /* OHHTTPStubs.m */,
|
||||
09793599161B62C0006DB5D5 /* OHHTTPStubsResponse.h */,
|
||||
0979359A161B62C0006DB5D5 /* OHHTTPStubsResponse.m */,
|
||||
);
|
||||
name = OHHTTPStubs;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
098368D4168FC7920082B1A4 /* UnitTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
099C734E1690394800239880 /* AFNetworking */,
|
||||
098368E5168FD0FF0082B1A4 /* Test Suites */,
|
||||
098368DA168FC7920082B1A4 /* AsyncSenTestCase.h */,
|
||||
098368DB168FC7920082B1A4 /* AsyncSenTestCase.m */,
|
||||
098368D5168FC7920082B1A4 /* Supporting Files */,
|
||||
);
|
||||
path = UnitTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
098368D5168FC7920082B1A4 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
098368D6168FC7920082B1A4 /* UnitTests-Info.plist */,
|
||||
098368DD168FC7920082B1A4 /* UnitTests-Prefix.pch */,
|
||||
099C735616903B9800239880 /* UIKit.framework */,
|
||||
098368CF168FC7920082B1A4 /* SenTestingKit.framework */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
098368E5168FD0FF0082B1A4 /* Test Suites */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
098368E3168FD0E50082B1A4 /* NSURLConnectionTests.m */,
|
||||
098368E9168FF9740082B1A4 /* NSURLConnectionDelegateTests.m */,
|
||||
098368EB169000340082B1A4 /* WithContentsOfURLTests.m */,
|
||||
09739F2B16900E81009851EF /* AFNetworkingTests.m */,
|
||||
);
|
||||
path = "Test Suites";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
099C734E1690394800239880 /* AFNetworking */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
099C734F1690397600239880 /* AFHTTPRequestOperation.h */,
|
||||
099C73501690397600239880 /* AFHTTPRequestOperation.m */,
|
||||
099C73521690397600239880 /* AFURLConnectionOperation.h */,
|
||||
099C73531690397600239880 /* AFURLConnectionOperation.m */,
|
||||
);
|
||||
name = AFNetworking;
|
||||
path = AFNetworking/AFNetworking;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
0979359D161B62EA006DB5D5 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0979359E161B62EF006DB5D5 /* OHHTTPStubs.h in Headers */,
|
||||
0979359F161B62EF006DB5D5 /* OHHTTPStubsResponse.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
09793578161B6251006DB5D5 /* OHHTTPStubs */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 09793587161B6251006DB5D5 /* Build configuration list for PBXNativeTarget "OHHTTPStubs" */;
|
||||
buildPhases = (
|
||||
09793575161B6251006DB5D5 /* Sources */,
|
||||
09793576161B6251006DB5D5 /* Frameworks */,
|
||||
0979359D161B62EA006DB5D5 /* Headers */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = OHHTTPStubs;
|
||||
productName = OHHTTPStubs;
|
||||
productReference = 09793579161B6251006DB5D5 /* libOHHTTPStubs.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
098368CD168FC7920082B1A4 /* UnitTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 098368E0168FC7920082B1A4 /* Build configuration list for PBXNativeTarget "UnitTests" */;
|
||||
buildPhases = (
|
||||
098368C9168FC7920082B1A4 /* Sources */,
|
||||
098368CA168FC7920082B1A4 /* Frameworks */,
|
||||
098368CB168FC7920082B1A4 /* Resources */,
|
||||
098368CC168FC7920082B1A4 /* ShellScript */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = UnitTests;
|
||||
productName = "OHHTTPStubs Unit Tests";
|
||||
productReference = 098368CE168FC7920082B1A4 /* UnitTests.octest */;
|
||||
productType = "com.apple.product-type.bundle";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
09793570161B6251006DB5D5 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0450;
|
||||
ORGANIZATIONNAME = AliSoftware;
|
||||
};
|
||||
buildConfigurationList = 09793573161B6251006DB5D5 /* Build configuration list for PBXProject "OHHTTPStubs" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 0979356E161B6251006DB5D5;
|
||||
productRefGroup = 0979357A161B6251006DB5D5 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
09793578161B6251006DB5D5 /* OHHTTPStubs */,
|
||||
098368CD168FC7920082B1A4 /* UnitTests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
098368CB168FC7920082B1A4 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
098368CC168FC7920082B1A4 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
09793575161B6251006DB5D5 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0979359B161B62C0006DB5D5 /* OHHTTPStubs.m in Sources */,
|
||||
0979359C161B62C0006DB5D5 /* OHHTTPStubsResponse.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
098368C9168FC7920082B1A4 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
098368DC168FC7920082B1A4 /* AsyncSenTestCase.m in Sources */,
|
||||
098368E4168FD0E50082B1A4 /* NSURLConnectionTests.m in Sources */,
|
||||
098368EA168FF9740082B1A4 /* NSURLConnectionDelegateTests.m in Sources */,
|
||||
098368EC169000340082B1A4 /* WithContentsOfURLTests.m in Sources */,
|
||||
09739F2C16900E81009851EF /* AFNetworkingTests.m in Sources */,
|
||||
099C73541690397600239880 /* AFHTTPRequestOperation.m in Sources */,
|
||||
099C73551690397600239880 /* AFURLConnectionOperation.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
09793585161B6251006DB5D5 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
09793586161B6251006DB5D5 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
09793588161B6251006DB5D5 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 097935A0161B644E006DB5D5 /* PortableLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
DSTROOT = /tmp/OHHTTPStubs.dst;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
09793589161B6251006DB5D5 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 097935A0161B644E006DB5D5 /* PortableLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
DSTROOT = /tmp/OHHTTPStubs.dst;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
098368DE168FC7920082B1A4 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
|
||||
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
|
||||
);
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "UnitTests/UnitTests-Prefix.pch";
|
||||
INFOPLIST_FILE = "UnitTests/UnitTests-Info.plist";
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = octest;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
098368DF168FC7920082B1A4 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
|
||||
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
|
||||
);
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "UnitTests/UnitTests-Prefix.pch";
|
||||
INFOPLIST_FILE = "UnitTests/UnitTests-Info.plist";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = octest;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
09793573161B6251006DB5D5 /* Build configuration list for PBXProject "OHHTTPStubs" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
09793585161B6251006DB5D5 /* Debug */,
|
||||
09793586161B6251006DB5D5 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
09793587161B6251006DB5D5 /* Build configuration list for PBXNativeTarget "OHHTTPStubs" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
09793588161B6251006DB5D5 /* Debug */,
|
||||
09793589161B6251006DB5D5 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
098368E0168FC7920082B1A4 /* Build configuration list for PBXNativeTarget "UnitTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
098368DE168FC7920082B1A4 /* Debug */,
|
||||
098368DF168FC7920082B1A4 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 09793570161B6251006DB5D5 /* Project object */;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0450"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "NO"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "09793578161B6251006DB5D5"
|
||||
BuildableName = "libOHHTTPStubs.a"
|
||||
BlueprintName = "OHHTTPStubs"
|
||||
ReferencedContainer = "container:OHHTTPStubs.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "098368CD168FC7920082B1A4"
|
||||
BuildableName = "UnitTests.octest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:OHHTTPStubs.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "AsyncSenTestCase">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,86 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
***********************************************************************************/
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Imports
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Defines & Constants
|
||||
|
||||
#define OHHTTPStubsResponseUseStub (OHHTTPStubsResponse*)@"DummyStub"
|
||||
#define OHHTTPStubsResponseDontUseStub (OHHTTPStubsResponse*)nil
|
||||
|
||||
// Standard download speeds.
|
||||
extern const double
|
||||
OHHTTPStubsDownloadSpeedGPRS,
|
||||
OHHTTPStubsDownloadSpeedEDGE,
|
||||
OHHTTPStubsDownloadSpeed3G,
|
||||
OHHTTPStubsDownloadSpeed3GPlus,
|
||||
OHHTTPStubsDownloadSpeedWifi;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Interface
|
||||
|
||||
@interface OHHTTPStubsResponse : NSObject
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Properties
|
||||
|
||||
@property(nonatomic, retain) NSDictionary* httpHeaders;
|
||||
@property(nonatomic, assign) int statusCode;
|
||||
@property(nonatomic, retain) NSData* responseData;
|
||||
//! @note if responseTime<0, it is interpreted as a download speed in KBps ( -200 => 200KB/s )
|
||||
@property(nonatomic, assign) NSTimeInterval responseTime;
|
||||
@property(nonatomic, retain) NSError* error;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Class Methods
|
||||
|
||||
+(OHHTTPStubsResponse*)responseWithData:(NSData*)data
|
||||
statusCode:(int)statusCode
|
||||
responseTime:(NSTimeInterval)responseTime
|
||||
headers:(NSDictionary*)httpHeaders;
|
||||
+(OHHTTPStubsResponse*)responseWithFile:(NSString*)fileName
|
||||
statusCode:(int)statusCode
|
||||
responseTime:(NSTimeInterval)responseTime
|
||||
headers:(NSDictionary*)httpHeaders;
|
||||
+(OHHTTPStubsResponse*)responseWithFile:(NSString*)fileName
|
||||
contentType:(NSString*)contentType
|
||||
responseTime:(NSTimeInterval)responseTime;
|
||||
+(OHHTTPStubsResponse*)responseWithError:(NSError*)error;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Instance Methods
|
||||
|
||||
-(OHHTTPStubsResponse*)initWithData:(NSData*)data
|
||||
statusCode:(int)statusCode
|
||||
responseTime:(NSTimeInterval)responseTime
|
||||
headers:(NSDictionary*)httpHeaders;
|
||||
-(OHHTTPStubsResponse*)initWithError:(NSError*)error;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,142 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
***********************************************************************************/
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Imports
|
||||
|
||||
#import "OHHTTPStubsResponse.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Defines & Constants
|
||||
|
||||
const double OHHTTPStubsDownloadSpeedGPRS =- 56 / 8; // kbps -> KB/s
|
||||
const double OHHTTPStubsDownloadSpeedEDGE =- 128 / 8; // kbps -> KB/s
|
||||
const double OHHTTPStubsDownloadSpeed3G =- 3200 / 8; // kbps -> KB/s
|
||||
const double OHHTTPStubsDownloadSpeed3GPlus =- 7200 / 8; // kbps -> KB/s
|
||||
const double OHHTTPStubsDownloadSpeedWifi =- 12000 / 8; // kbps -> KB/s
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Implementation
|
||||
|
||||
@implementation OHHTTPStubsResponse
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Synthesize
|
||||
|
||||
@synthesize httpHeaders = httpHeaders_;
|
||||
@synthesize statusCode = statusCode_;
|
||||
@synthesize responseData = responseData_;
|
||||
@synthesize responseTime = _responseTime;
|
||||
@synthesize error = error_;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Setup & Teardown
|
||||
|
||||
-(OHHTTPStubsResponse*)initWithData:(NSData*)data
|
||||
statusCode:(int)statusCode
|
||||
responseTime:(NSTimeInterval)responseTime
|
||||
headers:(NSDictionary*)httpHeaders
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.responseData = data;
|
||||
self.statusCode = statusCode;
|
||||
self.httpHeaders = httpHeaders;
|
||||
self.responseTime = responseTime;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(OHHTTPStubsResponse*)initWithError:(NSError*)error
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.error = error;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#if ! __has_feature(objc_arc)
|
||||
-(void)dealloc
|
||||
{
|
||||
self.httpHeaders = nil;
|
||||
self.statusCode = 0;
|
||||
self.responseData = nil;
|
||||
self.responseTime = 0;
|
||||
self.error = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Class Methods
|
||||
|
||||
+(OHHTTPStubsResponse*)responseWithData:(NSData*)data
|
||||
statusCode:(int)statusCode
|
||||
responseTime:(NSTimeInterval)responseTime
|
||||
headers:(NSDictionary*)httpHeaders
|
||||
{
|
||||
OHHTTPStubsResponse* response = [[self alloc] initWithData:data
|
||||
statusCode:statusCode
|
||||
responseTime:responseTime
|
||||
headers:httpHeaders];
|
||||
#if ! __has_feature(objc_arc)
|
||||
[response autorelease];
|
||||
#endif
|
||||
return response;
|
||||
}
|
||||
|
||||
+(OHHTTPStubsResponse*)responseWithFile:(NSString*)fileName
|
||||
statusCode:(int)statusCode
|
||||
responseTime:(NSTimeInterval)responseTime
|
||||
headers:(NSDictionary*)httpHeaders
|
||||
{
|
||||
NSString* basename = [fileName stringByDeletingPathExtension];
|
||||
NSString* extension = [fileName pathExtension];
|
||||
NSString* filePath = [[NSBundle bundleForClass:[self class]] pathForResource:basename ofType:extension];
|
||||
NSData* data = [NSData dataWithContentsOfFile:filePath];
|
||||
return [self responseWithData:data statusCode:statusCode responseTime:responseTime headers:httpHeaders];
|
||||
}
|
||||
|
||||
+(OHHTTPStubsResponse*)responseWithFile:(NSString*)fileName
|
||||
contentType:(NSString*)contentType
|
||||
responseTime:(NSTimeInterval)responseTime
|
||||
{
|
||||
NSDictionary* headers = [NSDictionary dictionaryWithObject:contentType forKey:@"Content-Type"];
|
||||
return [self responseWithFile:fileName statusCode:200 responseTime:responseTime headers:headers];
|
||||
}
|
||||
|
||||
|
||||
+(OHHTTPStubsResponse*)responseWithError:(NSError*)error
|
||||
{
|
||||
OHHTTPStubsResponse* response = [[self alloc] initWithError:error];
|
||||
#if ! __has_feature(objc_arc)
|
||||
[response autorelease];
|
||||
#endif
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// PortableLibrary.xcconfig
|
||||
// http://mrox.net/blog/2011/06/19/framework-like-static-libraries/
|
||||
//
|
||||
// Global configuration settings to generate a portable static library that will
|
||||
// - Compile gracefully in both Build and in Archive processes
|
||||
// - Reduce at its maximum the integration in the client application
|
||||
//
|
||||
// To integrate the library in your client application
|
||||
// - Add the library xcodeproj to your application's workspace
|
||||
// - Add the library to the "Link Binary With Libraries" section of the "Build Phase" tab of your application project
|
||||
// - use #import <LibraryName/Header.h> in your client files
|
||||
//
|
||||
|
||||
PUBLIC_HEADERS_FOLDER_PATH = include/$(PROJECT_NAME)
|
||||
INSTALL_PATH = /../BuildProductsPath/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/
|
||||
OTHER_LDFLAGS = -ObjC
|
||||
|
||||
// NOTE: be sure to configure SKIP_INSTALL to YES in Debug and NO in Release in this library project
|
||||
@@ -0,0 +1,18 @@
|
||||
# Xcode
|
||||
.DS_Store
|
||||
build/
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
*.xcworkspace
|
||||
!default.xcworkspace
|
||||
xcuserdata
|
||||
profile
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
.idea/
|
||||
@@ -0,0 +1,28 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'AFNetworking'
|
||||
s.version = '1.1.0'
|
||||
s.license = 'MIT'
|
||||
s.summary = 'A delightful iOS and OS X networking framework.'
|
||||
s.homepage = 'https://github.com/AFNetworking/AFNetworking'
|
||||
s.authors = { 'Mattt Thompson' => 'm@mattt.me', 'Scott Raymond' => 'sco@gowalla.com' }
|
||||
s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => '1.1.0' }
|
||||
s.source_files = 'AFNetworking'
|
||||
s.requires_arc = true
|
||||
|
||||
s.ios.deployment_target = '5.0'
|
||||
s.ios.frameworks = 'MobileCoreServices', 'SystemConfiguration'
|
||||
|
||||
s.osx.deployment_target = '10.7'
|
||||
s.osx.frameworks = 'CoreServices', 'SystemConfiguration'
|
||||
|
||||
s.prefix_header_contents = <<-EOS
|
||||
#import <Availability.h>
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
#import <SystemConfiguration/SystemConfiguration.h>
|
||||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
#else
|
||||
#import <SystemConfiguration/SystemConfiguration.h>
|
||||
#import <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
EOS
|
||||
end
|
||||
@@ -0,0 +1,581 @@
|
||||
// AFHTTPClient.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>
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
/**
|
||||
`AFHTTPClient` captures the common patterns of communicating with an web application over HTTP. It encapsulates information like base URL, authorization credentials, and HTTP headers, and uses them to construct and manage the execution of HTTP request operations.
|
||||
|
||||
## Automatic Content Parsing
|
||||
|
||||
Instances of `AFHTTPClient` may specify which types of requests it expects and should handle by registering HTTP operation classes for automatic parsing. Registered classes will determine whether they can handle a particular request, and then construct a request operation accordingly in `enqueueHTTPRequestOperationWithRequest:success:failure`.
|
||||
|
||||
## Subclassing Notes
|
||||
|
||||
In most cases, one should create an `AFHTTPClient` subclass for each website or web application that your application communicates with. It is often useful, also, to define a class method that returns a singleton shared HTTP client in each subclass, that persists authentication credentials and other configuration across the entire application.
|
||||
|
||||
## Methods to Override
|
||||
|
||||
To change the behavior of all url request construction for an `AFHTTPClient` subclass, override `requestWithMethod:path:parameters`.
|
||||
|
||||
To change the behavior of all request operation construction for an `AFHTTPClient` subclass, override `HTTPRequestOperationWithRequest:success:failure`.
|
||||
|
||||
## Default Headers
|
||||
|
||||
By default, `AFHTTPClient` sets the following HTTP headers:
|
||||
|
||||
- `Accept-Language: (comma-delimited preferred languages), en-us;q=0.8`
|
||||
- `User-Agent: (generated user agent)`
|
||||
|
||||
You can override these HTTP headers or define new ones using `setDefaultHeader:value:`.
|
||||
|
||||
## URL Construction Using Relative Paths
|
||||
|
||||
Both `-requestWithMethod:path:parameters:` and `-multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:` construct URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`. Below are a few examples of how `baseURL` and relative paths interact:
|
||||
|
||||
NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
|
||||
[NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
|
||||
[NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
|
||||
[NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
|
||||
[NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
|
||||
[NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
|
||||
[NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
|
||||
|
||||
Also important to note is that a trailing slash will be added to any `baseURL` without one, which would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
|
||||
|
||||
## NSCoding / NSCopying Conformance
|
||||
|
||||
`AFHTTPClient` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however:
|
||||
|
||||
- Archives and copies of HTTP clients will be initialized with an empty operation queue.
|
||||
- NSCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set.
|
||||
*/
|
||||
|
||||
#ifdef _SYSTEMCONFIGURATION_H
|
||||
typedef enum {
|
||||
AFNetworkReachabilityStatusUnknown = -1,
|
||||
AFNetworkReachabilityStatusNotReachable = 0,
|
||||
AFNetworkReachabilityStatusReachableViaWWAN = 1,
|
||||
AFNetworkReachabilityStatusReachableViaWiFi = 2,
|
||||
} AFNetworkReachabilityStatus;
|
||||
#else
|
||||
#warning SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available.
|
||||
#endif
|
||||
|
||||
#ifndef __UTTYPE__
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
#warning MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.
|
||||
#else
|
||||
#warning CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
AFFormURLParameterEncoding,
|
||||
AFJSONParameterEncoding,
|
||||
AFPropertyListParameterEncoding,
|
||||
} AFHTTPClientParameterEncoding;
|
||||
|
||||
@class AFHTTPRequestOperation;
|
||||
@protocol AFMultipartFormData;
|
||||
|
||||
@interface AFHTTPClient : NSObject <NSCoding, NSCopying>
|
||||
|
||||
///---------------------------------------
|
||||
/// @name Accessing HTTP Client Properties
|
||||
///---------------------------------------
|
||||
|
||||
/**
|
||||
The url used as the base for paths specified in methods such as `getPath:parameters:success:failure`
|
||||
*/
|
||||
@property (readonly, nonatomic) NSURL *baseURL;
|
||||
|
||||
/**
|
||||
The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default.
|
||||
*/
|
||||
@property (nonatomic, assign) NSStringEncoding stringEncoding;
|
||||
|
||||
/**
|
||||
The `AFHTTPClientParameterEncoding` value corresponding to how parameters are encoded into a request body. This is `AFFormURLParameterEncoding` by default.
|
||||
|
||||
@warning Some nested parameter structures, such as a keyed array of hashes containing inconsistent keys (i.e. `@{@"": @[@{@"a" : @(1)}, @{@"b" : @(2)}]}`), cannot be unambiguously represented in query strings. It is strongly recommended that an unambiguous encoding, such as `AFJSONParameterEncoding`, is used when posting complicated or nondeterministic parameter structures.
|
||||
*/
|
||||
@property (nonatomic, assign) AFHTTPClientParameterEncoding parameterEncoding;
|
||||
|
||||
/**
|
||||
The operation queue which manages operations enqueued by the HTTP client.
|
||||
*/
|
||||
@property (readonly, nonatomic) NSOperationQueue *operationQueue;
|
||||
|
||||
/**
|
||||
The reachability status from the device to the current `baseURL` of the `AFHTTPClient`.
|
||||
|
||||
@warning This property requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
|
||||
*/
|
||||
#ifdef _SYSTEMCONFIGURATION_H
|
||||
@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
|
||||
#endif
|
||||
|
||||
///---------------------------------------------
|
||||
/// @name Creating and Initializing HTTP Clients
|
||||
///---------------------------------------------
|
||||
|
||||
/**
|
||||
Creates and initializes an `AFHTTPClient` object with the specified base URL.
|
||||
|
||||
@param url The base URL for the HTTP client. This argument must not be `nil`.
|
||||
|
||||
@return The newly-initialized HTTP client
|
||||
*/
|
||||
+ (instancetype)clientWithBaseURL:(NSURL *)url;
|
||||
|
||||
/**
|
||||
Initializes an `AFHTTPClient` object with the specified base URL.
|
||||
|
||||
@param url The base URL for the HTTP client. This argument must not be `nil`.
|
||||
|
||||
@discussion This is the designated initializer.
|
||||
|
||||
@return The newly-initialized HTTP client
|
||||
*/
|
||||
- (id)initWithBaseURL:(NSURL *)url;
|
||||
|
||||
///-----------------------------------
|
||||
/// @name Managing Reachability Status
|
||||
///-----------------------------------
|
||||
|
||||
/**
|
||||
Sets a callback to be executed when the network availability of the `baseURL` host changes.
|
||||
|
||||
@param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
|
||||
|
||||
@warning This method requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
|
||||
*/
|
||||
#ifdef _SYSTEMCONFIGURATION_H
|
||||
- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block;
|
||||
#endif
|
||||
|
||||
///-------------------------------
|
||||
/// @name Managing HTTP Operations
|
||||
///-------------------------------
|
||||
|
||||
/**
|
||||
Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request.
|
||||
|
||||
@param operationClass The subclass of `AFHTTPRequestOperation` to register
|
||||
|
||||
@return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`.
|
||||
|
||||
@discussion When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list.
|
||||
*/
|
||||
- (BOOL)registerHTTPOperationClass:(Class)operationClass;
|
||||
|
||||
/**
|
||||
Unregisters the specified subclass of `AFHTTPRequestOperation` from the chain of classes consulted when `-requestWithMethod:path:parameters` is called.
|
||||
|
||||
@param operationClass The subclass of `AFHTTPRequestOperation` to register
|
||||
*/
|
||||
- (void)unregisterHTTPOperationClass:(Class)operationClass;
|
||||
|
||||
///----------------------------------
|
||||
/// @name Managing HTTP Header Values
|
||||
///----------------------------------
|
||||
|
||||
/**
|
||||
Returns the value for the HTTP headers set in request objects created by the HTTP client.
|
||||
|
||||
@param header The HTTP header to return the default value for
|
||||
|
||||
@return The default value for the HTTP header, or `nil` if unspecified
|
||||
*/
|
||||
- (NSString *)defaultValueForHeader:(NSString *)header;
|
||||
|
||||
/**
|
||||
Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
|
||||
|
||||
@param header The HTTP header to set a default value for
|
||||
@param value The value set as default for the specified header, or `nil
|
||||
*/
|
||||
- (void)setDefaultHeader:(NSString *)header value:(NSString *)value;
|
||||
|
||||
/**
|
||||
Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
|
||||
|
||||
@param username The HTTP basic auth username
|
||||
@param password The HTTP basic auth password
|
||||
*/
|
||||
- (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password;
|
||||
|
||||
/**
|
||||
Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header.
|
||||
|
||||
@param token The authentication token
|
||||
*/
|
||||
- (void)setAuthorizationHeaderWithToken:(NSString *)token;
|
||||
|
||||
/**
|
||||
Clears any existing value for the "Authorization" HTTP header.
|
||||
*/
|
||||
- (void)clearAuthorizationHeader;
|
||||
|
||||
///-------------------------------
|
||||
/// @name Creating Request Objects
|
||||
///-------------------------------
|
||||
|
||||
/**
|
||||
Creates an `NSMutableURLRequest` object with the specified HTTP method and path.
|
||||
|
||||
If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body.
|
||||
|
||||
@param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
|
||||
@param path The path to be appended to the HTTP client's base URL and used as the request URL. If `nil`, no path will be appended to the base URL.
|
||||
@param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
|
||||
|
||||
@return An `NSMutableURLRequest` object
|
||||
*/
|
||||
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
|
||||
path:(NSString *)path
|
||||
parameters:(NSDictionary *)parameters;
|
||||
|
||||
/**
|
||||
Creates an `NSMutableURLRequest` object with the specified HTTP method and path, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
|
||||
|
||||
@param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
|
||||
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
||||
@param parameters The parameters to be encoded and set in the request HTTP body.
|
||||
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. This can be used to upload files, encode HTTP body as JSON or XML, or specify multiple values for the same parameter, as one might for array values.
|
||||
|
||||
@discussion Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.
|
||||
|
||||
@return An `NSMutableURLRequest` object
|
||||
*/
|
||||
- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
|
||||
path:(NSString *)path
|
||||
parameters:(NSDictionary *)parameters
|
||||
constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block;
|
||||
|
||||
///-------------------------------
|
||||
/// @name Creating HTTP Operations
|
||||
///-------------------------------
|
||||
|
||||
/**
|
||||
Creates an `AFHTTPRequestOperation`.
|
||||
|
||||
In order to determine what kind of operation is created, each registered subclass conforming to the `AFHTTPClient` protocol is consulted (in reverse order of when they were specified) to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to generate an operation using `HTTPRequestOperationWithRequest:success:failure:`.
|
||||
|
||||
@param urlRequest The request object to be loaded asynchronously during execution of the operation.
|
||||
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
||||
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
||||
*/
|
||||
- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
||||
|
||||
///----------------------------------------
|
||||
/// @name Managing Enqueued HTTP Operations
|
||||
///----------------------------------------
|
||||
|
||||
/**
|
||||
Enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue.
|
||||
|
||||
@param operation The HTTP request operation to be enqueued.
|
||||
*/
|
||||
- (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation;
|
||||
|
||||
/**
|
||||
Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path.
|
||||
|
||||
@param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled.
|
||||
@param path The path appended to the HTTP client base URL to match against the cancelled requests. If `nil`, no path will be appended to the base URL.
|
||||
|
||||
@discussion This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property.
|
||||
*/
|
||||
- (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path;
|
||||
|
||||
///---------------------------------------
|
||||
/// @name Batching HTTP Request Operations
|
||||
///---------------------------------------
|
||||
|
||||
/**
|
||||
Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue for each specified request object into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
|
||||
|
||||
@param urlRequests The `NSURLRequest` objects used to create and enqueue operations.
|
||||
@param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
|
||||
@param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations.
|
||||
|
||||
@discussion Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters.
|
||||
*/
|
||||
- (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests
|
||||
progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
|
||||
completionBlock:(void (^)(NSArray *operations))completionBlock;
|
||||
|
||||
/**
|
||||
Enqueues the specified request operations into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
|
||||
|
||||
@param operations The request operations used to be batched and enqueued.
|
||||
@param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
|
||||
@param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations.
|
||||
*/
|
||||
- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations
|
||||
progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
|
||||
completionBlock:(void (^)(NSArray *operations))completionBlock;
|
||||
|
||||
///---------------------------
|
||||
/// @name Making HTTP Requests
|
||||
///---------------------------
|
||||
|
||||
/**
|
||||
Creates an `AFHTTPRequestOperation` with a `GET` request, and enqueues it to the HTTP client's operation queue.
|
||||
|
||||
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
||||
@param parameters The parameters to be encoded and appended as the query string for the request URL.
|
||||
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
||||
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
||||
|
||||
@see -HTTPRequestOperationWithRequest:success:failure:
|
||||
*/
|
||||
- (void)getPath:(NSString *)path
|
||||
parameters:(NSDictionary *)parameters
|
||||
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates an `AFHTTPRequestOperation` with a `POST` request, and enqueues it to the HTTP client's operation queue.
|
||||
|
||||
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
||||
@param parameters The parameters to be encoded and set in the request HTTP body.
|
||||
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
||||
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
||||
|
||||
@see -HTTPRequestOperationWithRequest:success:failure:
|
||||
*/
|
||||
- (void)postPath:(NSString *)path
|
||||
parameters:(NSDictionary *)parameters
|
||||
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates an `AFHTTPRequestOperation` with a `PUT` request, and enqueues it to the HTTP client's operation queue.
|
||||
|
||||
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
||||
@param parameters The parameters to be encoded and set in the request HTTP body.
|
||||
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
||||
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
||||
|
||||
@see -HTTPRequestOperationWithRequest:success:failure:
|
||||
*/
|
||||
- (void)putPath:(NSString *)path
|
||||
parameters:(NSDictionary *)parameters
|
||||
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates an `AFHTTPRequestOperation` with a `DELETE` request, and enqueues it to the HTTP client's operation queue.
|
||||
|
||||
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
||||
@param parameters The parameters to be encoded and appended as the query string for the request URL.
|
||||
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
||||
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
||||
|
||||
@see -HTTPRequestOperationWithRequest:success:failure:
|
||||
*/
|
||||
- (void)deletePath:(NSString *)path
|
||||
parameters:(NSDictionary *)parameters
|
||||
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates an `AFHTTPRequestOperation` with a `PATCH` request, and enqueues it to the HTTP client's operation queue.
|
||||
|
||||
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
||||
@param parameters The parameters to be encoded and set in the request HTTP body.
|
||||
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
||||
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
||||
|
||||
@see -HTTPRequestOperationWithRequest:success:failure:
|
||||
*/
|
||||
- (void)patchPath:(NSString *)path
|
||||
parameters:(NSDictionary *)parameters
|
||||
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
||||
@end
|
||||
|
||||
///----------------
|
||||
/// @name Constants
|
||||
///----------------
|
||||
|
||||
/**
|
||||
### Network Reachability
|
||||
|
||||
The following constants are provided by `AFHTTPClient` as possible network reachability statuses.
|
||||
|
||||
enum {
|
||||
AFNetworkReachabilityStatusUnknown,
|
||||
AFNetworkReachabilityStatusNotReachable,
|
||||
AFNetworkReachabilityStatusReachableViaWWAN,
|
||||
AFNetworkReachabilityStatusReachableViaWiFi,
|
||||
}
|
||||
|
||||
`AFNetworkReachabilityStatusUnknown`
|
||||
The `baseURL` host reachability is not known.
|
||||
|
||||
`AFNetworkReachabilityStatusNotReachable`
|
||||
The `baseURL` host cannot be reached.
|
||||
|
||||
`AFNetworkReachabilityStatusReachableViaWWAN`
|
||||
The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
|
||||
|
||||
`AFNetworkReachabilityStatusReachableViaWiFi`
|
||||
The `baseURL` host can be reached via a Wi-Fi connection.
|
||||
|
||||
### Keys for Notification UserInfo Dictionary
|
||||
|
||||
Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
|
||||
|
||||
`AFNetworkingReachabilityNotificationStatusItem`
|
||||
A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
|
||||
The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
|
||||
|
||||
### Parameter Encoding
|
||||
|
||||
The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values.
|
||||
|
||||
enum {
|
||||
AFFormURLParameterEncoding,
|
||||
AFJSONParameterEncoding,
|
||||
AFPropertyListParameterEncoding,
|
||||
}
|
||||
|
||||
`AFFormURLParameterEncoding`
|
||||
Parameters are encoded into field/key pairs in the URL query string for `GET` `HEAD` and `DELETE` requests, and in the message body otherwise. Dictionary keys are sorted with the `caseInsensitiveCompare:` selector of their description, in order to mitigate the possibility of ambiguous query strings being generated non-deterministically. See the warning for the `parameterEncoding` property for additional information.
|
||||
|
||||
`AFJSONParameterEncoding`
|
||||
Parameters are encoded into JSON in the message body.
|
||||
|
||||
`AFPropertyListParameterEncoding`
|
||||
Parameters are encoded into a property list in the message body.
|
||||
*/
|
||||
|
||||
///----------------
|
||||
/// @name Functions
|
||||
///----------------
|
||||
|
||||
/**
|
||||
Returns a query string constructed by a set of parameters, using the specified encoding.
|
||||
|
||||
@param parameters The parameters used to construct the query string
|
||||
@param encoding The encoding to use in constructing the query string. If you are uncertain of the correct encoding, you should use UTF-8 (`NSUTF8StringEncoding`), which is the encoding designated by RFC 3986 as the correct encoding for use in URLs.
|
||||
|
||||
@discussion Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&".
|
||||
|
||||
If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component.
|
||||
|
||||
@return A percent-escaped query string
|
||||
*/
|
||||
extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding);
|
||||
|
||||
///--------------------
|
||||
/// @name Notifications
|
||||
///--------------------
|
||||
|
||||
/**
|
||||
Posted when network reachability changes.
|
||||
This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
|
||||
|
||||
@warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
|
||||
*/
|
||||
#ifdef _SYSTEMCONFIGURATION_H
|
||||
extern NSString * const AFNetworkingReachabilityDidChangeNotification;
|
||||
extern NSString * const AFNetworkingReachabilityNotificationStatusItem;
|
||||
#endif
|
||||
|
||||
#pragma mark -
|
||||
|
||||
extern NSUInteger const kAFUploadStream3GSuggestedPacketSize;
|
||||
extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
|
||||
|
||||
/**
|
||||
The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPClient -multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:`.
|
||||
*/
|
||||
@protocol AFMultipartFormData
|
||||
|
||||
/**
|
||||
Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
|
||||
|
||||
@param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
|
||||
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||
@param error If an error occurs, upon return contains an `NSError` object that describes the problem.
|
||||
|
||||
@return `YES` if the file data was successfully appended, otherwise `NO`.
|
||||
|
||||
@discussion The filename and MIME type for this data in the form will be automatically generated, using `NSURLResponse` `-suggestedFilename` and `-MIMEType`, respectively.
|
||||
*/
|
||||
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
|
||||
name:(NSString *)name
|
||||
error:(NSError * __autoreleasing *)error;
|
||||
|
||||
/**
|
||||
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
|
||||
|
||||
@param data The data to be encoded and appended to the form data.
|
||||
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||
@param filename The filename to be associated with the specified data. This parameter must not be `nil`.
|
||||
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
|
||||
*/
|
||||
- (void)appendPartWithFileData:(NSData *)data
|
||||
name:(NSString *)name
|
||||
fileName:(NSString *)fileName
|
||||
mimeType:(NSString *)mimeType;
|
||||
|
||||
/**
|
||||
Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
|
||||
|
||||
@param data The data to be encoded and appended to the form data.
|
||||
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||
*/
|
||||
|
||||
- (void)appendPartWithFormData:(NSData *)data
|
||||
name:(NSString *)name;
|
||||
|
||||
/**
|
||||
Appends HTTP headers, followed by the encoded data and the multipart form boundary.
|
||||
|
||||
@param headers The HTTP headers to be appended to the form data.
|
||||
@param body The data to be encoded and appended to the form data.
|
||||
*/
|
||||
- (void)appendPartWithHeaders:(NSDictionary *)headers
|
||||
body:(NSData *)body;
|
||||
|
||||
/**
|
||||
Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
|
||||
|
||||
@param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 32kb.
|
||||
@param delay Duration of delay each time a packet is read. By default, no delay is set.
|
||||
|
||||
@discussion When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
|
||||
*/
|
||||
- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
|
||||
delay:(NSTimeInterval)delay;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,133 @@
|
||||
// AFHTTPRequestOperation.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>
|
||||
#import "AFURLConnectionOperation.h"
|
||||
|
||||
/**
|
||||
`AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.
|
||||
*/
|
||||
@interface AFHTTPRequestOperation : AFURLConnectionOperation
|
||||
|
||||
///----------------------------------------------
|
||||
/// @name Getting HTTP URL Connection Information
|
||||
///----------------------------------------------
|
||||
|
||||
/**
|
||||
The last HTTP response received by the operation's connection.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSHTTPURLResponse *response;
|
||||
|
||||
///----------------------------------------------------------
|
||||
/// @name Managing And Checking For Acceptable HTTP Responses
|
||||
///----------------------------------------------------------
|
||||
|
||||
/**
|
||||
A Boolean value that corresponds to whether the status code of the response is within the specified set of acceptable status codes. Returns `YES` if `acceptableStatusCodes` is `nil`.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL hasAcceptableStatusCode;
|
||||
|
||||
/**
|
||||
A Boolean value that corresponds to whether the MIME type of the response is among the specified set of acceptable content types. Returns `YES` if `acceptableContentTypes` is `nil`.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL hasAcceptableContentType;
|
||||
|
||||
/**
|
||||
The callback dispatch queue on success. If `NULL` (default), the main queue is used.
|
||||
*/
|
||||
@property (nonatomic, assign) dispatch_queue_t successCallbackQueue;
|
||||
|
||||
/**
|
||||
The callback dispatch queue on failure. If `NULL` (default), the main queue is used.
|
||||
*/
|
||||
@property (nonatomic, assign) dispatch_queue_t failureCallbackQueue;
|
||||
|
||||
///------------------------------------------------------------
|
||||
/// @name Managing Acceptable HTTP Status Codes & Content Types
|
||||
///------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Returns an `NSIndexSet` object containing the ranges of acceptable HTTP status codes. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
||||
|
||||
By default, this is the range 200 to 299, inclusive.
|
||||
*/
|
||||
+ (NSIndexSet *)acceptableStatusCodes;
|
||||
|
||||
/**
|
||||
Adds status codes to the set of acceptable HTTP status codes returned by `+acceptableStatusCodes` in subsequent calls by this class and its descendants.
|
||||
|
||||
@param statusCodes The status codes to be added to the set of acceptable HTTP status codes
|
||||
*/
|
||||
+ (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes;
|
||||
|
||||
/**
|
||||
Returns an `NSSet` object containing the acceptable MIME types. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
|
||||
|
||||
By default, this is `nil`.
|
||||
*/
|
||||
+ (NSSet *)acceptableContentTypes;
|
||||
|
||||
/**
|
||||
Adds content types to the set of acceptable MIME types returned by `+acceptableContentTypes` in subsequent calls by this class and its descendants.
|
||||
|
||||
@param contentTypes The content types to be added to the set of acceptable MIME types
|
||||
*/
|
||||
+ (void)addAcceptableContentTypes:(NSSet *)contentTypes;
|
||||
|
||||
|
||||
///-----------------------------------------------------
|
||||
/// @name Determining Whether A Request Can Be Processed
|
||||
///-----------------------------------------------------
|
||||
|
||||
/**
|
||||
A Boolean value determining whether or not the class can process the specified request. For example, `AFJSONRequestOperation` may check to make sure the content type was `application/json` or the URL path extension was `.json`.
|
||||
|
||||
@param urlRequest The request that is determined to be supported or not supported for this class.
|
||||
*/
|
||||
+ (BOOL)canProcessRequest:(NSURLRequest *)urlRequest;
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Setting Completion Block Success / Failure Callbacks
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed.
|
||||
|
||||
@param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request.
|
||||
@param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request.
|
||||
|
||||
@discussion This method should be overridden in subclasses in order to specify the response object passed into the success block.
|
||||
*/
|
||||
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
||||
|
||||
@end
|
||||
|
||||
///----------------
|
||||
/// @name Functions
|
||||
///----------------
|
||||
|
||||
/**
|
||||
Returns a set of MIME types detected in an HTTP `Accept` or `Content-Type` header.
|
||||
*/
|
||||
extern NSSet * AFContentTypesFromHTTPHeader(NSString *string);
|
||||
|
||||
@@ -0,0 +1,369 @@
|
||||
// AFHTTPRequestOperation.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 "AFHTTPRequestOperation.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
// Workaround for change in imp_implementationWithBlock() with Xcode 4.5
|
||||
#if defined(__IPHONE_6_0) || defined(__MAC_10_8)
|
||||
#define AF_CAST_TO_BLOCK id
|
||||
#else
|
||||
#define AF_CAST_TO_BLOCK __bridge void *
|
||||
#endif
|
||||
|
||||
// We do a little bit of duck typing in this file which can trigger this warning. Turn it off for this source file.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wstrict-selector-match"
|
||||
|
||||
NSSet * AFContentTypesFromHTTPHeader(NSString *string) {
|
||||
if (!string) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSArray *mediaRanges = [string componentsSeparatedByString:@","];
|
||||
NSMutableSet *mutableContentTypes = [NSMutableSet setWithCapacity:mediaRanges.count];
|
||||
|
||||
[mediaRanges enumerateObjectsUsingBlock:^(NSString *mediaRange, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
NSRange parametersRange = [mediaRange rangeOfString:@";"];
|
||||
if (parametersRange.location != NSNotFound) {
|
||||
mediaRange = [mediaRange substringToIndex:parametersRange.location];
|
||||
}
|
||||
|
||||
mediaRange = [mediaRange stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
|
||||
if (mediaRange.length > 0) {
|
||||
[mutableContentTypes addObject:mediaRange];
|
||||
}
|
||||
}];
|
||||
|
||||
return [NSSet setWithSet:mutableContentTypes];
|
||||
}
|
||||
|
||||
static void AFGetMediaTypeAndSubtypeWithString(NSString *string, NSString **type, NSString **subtype) {
|
||||
NSScanner *scanner = [NSScanner scannerWithString:string];
|
||||
[scanner setCharactersToBeSkipped:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
[scanner scanUpToString:@"/" intoString:type];
|
||||
[scanner scanString:@"/" intoString:nil];
|
||||
[scanner scanUpToString:@";" intoString:subtype];
|
||||
}
|
||||
|
||||
static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
|
||||
NSMutableString *string = [NSMutableString string];
|
||||
|
||||
NSRange range = NSMakeRange([indexSet firstIndex], 1);
|
||||
while (range.location != NSNotFound) {
|
||||
NSUInteger nextIndex = [indexSet indexGreaterThanIndex:range.location];
|
||||
while (nextIndex == range.location + range.length) {
|
||||
range.length++;
|
||||
nextIndex = [indexSet indexGreaterThanIndex:nextIndex];
|
||||
}
|
||||
|
||||
if (string.length) {
|
||||
[string appendString:@","];
|
||||
}
|
||||
|
||||
if (range.length == 1) {
|
||||
[string appendFormat:@"%lu", (long)range.location];
|
||||
} else {
|
||||
NSUInteger firstIndex = range.location;
|
||||
NSUInteger lastIndex = firstIndex + range.length - 1;
|
||||
[string appendFormat:@"%lu-%lu", (long)firstIndex, (long)lastIndex];
|
||||
}
|
||||
|
||||
range.location = nextIndex;
|
||||
range.length = 1;
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL selector, id block) {
|
||||
Method originalMethod = class_getClassMethod(klass, selector);
|
||||
IMP implementation = imp_implementationWithBlock((AF_CAST_TO_BLOCK)block);
|
||||
class_replaceMethod(objc_getMetaClass([NSStringFromClass(klass) UTF8String]), selector, implementation, method_getTypeEncoding(originalMethod));
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface AFHTTPRequestOperation ()
|
||||
@property (readwrite, nonatomic, strong) NSURLRequest *request;
|
||||
@property (readwrite, nonatomic, strong) NSHTTPURLResponse *response;
|
||||
@property (readwrite, nonatomic, strong) NSError *HTTPError;
|
||||
@property (readwrite, nonatomic, copy) NSString *HTTPResponseString;
|
||||
@property (readwrite, nonatomic, assign) long long totalContentLength;
|
||||
@property (readwrite, nonatomic, assign) long long offsetContentLength;
|
||||
@end
|
||||
|
||||
@implementation AFHTTPRequestOperation
|
||||
@synthesize HTTPError = _HTTPError;
|
||||
@synthesize HTTPResponseString = _HTTPResponseString;
|
||||
@synthesize successCallbackQueue = _successCallbackQueue;
|
||||
@synthesize failureCallbackQueue = _failureCallbackQueue;
|
||||
@synthesize totalContentLength = _totalContentLength;
|
||||
@synthesize offsetContentLength = _offsetContentLength;
|
||||
@dynamic request;
|
||||
@dynamic response;
|
||||
|
||||
- (void)dealloc {
|
||||
if (_successCallbackQueue) {
|
||||
#if !OS_OBJECT_USE_OBJC
|
||||
dispatch_release(_successCallbackQueue);
|
||||
#endif
|
||||
_successCallbackQueue = NULL;
|
||||
}
|
||||
|
||||
if (_failureCallbackQueue) {
|
||||
#if !OS_OBJECT_USE_OBJC
|
||||
dispatch_release(_failureCallbackQueue);
|
||||
#endif
|
||||
_failureCallbackQueue = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSError *)error {
|
||||
if (!self.HTTPError && self.response) {
|
||||
if (![self hasAcceptableStatusCode] || ![self hasAcceptableContentType]) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
[userInfo setValue:self.responseString forKey:NSLocalizedRecoverySuggestionErrorKey];
|
||||
[userInfo setValue:[self.request URL] forKey:NSURLErrorFailingURLErrorKey];
|
||||
[userInfo setValue:self.request forKey:AFNetworkingOperationFailingURLRequestErrorKey];
|
||||
[userInfo setValue:self.response forKey:AFNetworkingOperationFailingURLResponseErrorKey];
|
||||
|
||||
if (![self hasAcceptableStatusCode]) {
|
||||
NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200;
|
||||
[userInfo setValue:[NSString stringWithFormat:NSLocalizedStringFromTable(@"Expected status code in (%@), got %d", @"AFNetworking", nil), AFStringFromIndexSet([[self class] acceptableStatusCodes]), statusCode] forKey:NSLocalizedDescriptionKey];
|
||||
self.HTTPError = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadServerResponse userInfo:userInfo];
|
||||
} else if (![self hasAcceptableContentType]) {
|
||||
// Don't invalidate content type if there is no content
|
||||
if ([self.responseData length] > 0) {
|
||||
[userInfo setValue:[NSString stringWithFormat:NSLocalizedStringFromTable(@"Expected content type %@, got %@", @"AFNetworking", nil), [[self class] acceptableContentTypes], [self.response MIMEType]] forKey:NSLocalizedDescriptionKey];
|
||||
self.HTTPError = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self.HTTPError) {
|
||||
return self.HTTPError;
|
||||
} else {
|
||||
return [super error];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)responseString {
|
||||
// When no explicit charset parameter is provided by the sender, media subtypes of the "text" type are defined to have a default charset value of "ISO-8859-1" when received via HTTP. Data in character sets other than "ISO-8859-1" or its subsets MUST be labeled with an appropriate charset value.
|
||||
// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.4.1
|
||||
if (!self.HTTPResponseString && self.response && !self.response.textEncodingName && self.responseData) {
|
||||
NSString *type = nil;
|
||||
AFGetMediaTypeAndSubtypeWithString([[self.response allHeaderFields] valueForKey:@"Content-Type"], &type, nil);
|
||||
|
||||
if ([type isEqualToString:@"text"]) {
|
||||
self.HTTPResponseString = [[NSString alloc] initWithData:self.responseData encoding:NSISOLatin1StringEncoding];
|
||||
}
|
||||
}
|
||||
|
||||
if (self.HTTPResponseString) {
|
||||
return self.HTTPResponseString;
|
||||
} else {
|
||||
return [super responseString];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pause {
|
||||
unsigned long long offset = 0;
|
||||
if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) {
|
||||
offset = [[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue];
|
||||
} else {
|
||||
offset = [[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length];
|
||||
}
|
||||
|
||||
NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy];
|
||||
if ([[self.response allHeaderFields] valueForKey:@"ETag"]) {
|
||||
[mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"];
|
||||
}
|
||||
[mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"];
|
||||
self.request = mutableURLRequest;
|
||||
|
||||
[super pause];
|
||||
}
|
||||
|
||||
- (BOOL)hasAcceptableStatusCode {
|
||||
if (!self.response) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200;
|
||||
return ![[self class] acceptableStatusCodes] || [[[self class] acceptableStatusCodes] containsIndex:statusCode];
|
||||
}
|
||||
|
||||
- (BOOL)hasAcceptableContentType {
|
||||
if (!self.response) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and/or the name extension(s) of the URI used to identify the resource. If the media type remains unknown, the recipient SHOULD treat it as type "application/octet-stream".
|
||||
// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html
|
||||
NSString *contentType = [self.response MIMEType];
|
||||
if (!contentType) {
|
||||
contentType = @"application/octet-stream";
|
||||
}
|
||||
|
||||
return ![[self class] acceptableContentTypes] || [[[self class] acceptableContentTypes] containsObject:contentType];
|
||||
}
|
||||
|
||||
- (void)setSuccessCallbackQueue:(dispatch_queue_t)successCallbackQueue {
|
||||
if (successCallbackQueue != _successCallbackQueue) {
|
||||
if (_successCallbackQueue) {
|
||||
#if !OS_OBJECT_USE_OBJC
|
||||
dispatch_release(_successCallbackQueue);
|
||||
#endif
|
||||
_successCallbackQueue = NULL;
|
||||
}
|
||||
|
||||
if (successCallbackQueue) {
|
||||
#if !OS_OBJECT_USE_OBJC
|
||||
dispatch_retain(successCallbackQueue);
|
||||
#endif
|
||||
_successCallbackQueue = successCallbackQueue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setFailureCallbackQueue:(dispatch_queue_t)failureCallbackQueue {
|
||||
if (failureCallbackQueue != _failureCallbackQueue) {
|
||||
if (_failureCallbackQueue) {
|
||||
#if !OS_OBJECT_USE_OBJC
|
||||
dispatch_release(_failureCallbackQueue);
|
||||
#endif
|
||||
_failureCallbackQueue = NULL;
|
||||
}
|
||||
|
||||
if (failureCallbackQueue) {
|
||||
#if !OS_OBJECT_USE_OBJC
|
||||
dispatch_retain(failureCallbackQueue);
|
||||
#endif
|
||||
_failureCallbackQueue = failureCallbackQueue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
|
||||
{
|
||||
// completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
self.completionBlock = ^{
|
||||
if (self.error) {
|
||||
if (failure) {
|
||||
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
failure(self, self.error);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (success) {
|
||||
dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
success(self, self.responseData);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
#pragma mark - AFHTTPRequestOperation
|
||||
|
||||
+ (NSIndexSet *)acceptableStatusCodes {
|
||||
return [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)];
|
||||
}
|
||||
|
||||
+ (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes {
|
||||
NSMutableIndexSet *mutableStatusCodes = [[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]];
|
||||
[mutableStatusCodes addIndexes:statusCodes];
|
||||
AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(__unused id _self) {
|
||||
return mutableStatusCodes;
|
||||
});
|
||||
}
|
||||
|
||||
+ (NSSet *)acceptableContentTypes {
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void)addAcceptableContentTypes:(NSSet *)contentTypes {
|
||||
NSMutableSet *mutableContentTypes = [[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES];
|
||||
[mutableContentTypes unionSet:contentTypes];
|
||||
AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(__unused id _self) {
|
||||
return mutableContentTypes;
|
||||
});
|
||||
}
|
||||
|
||||
+ (BOOL)canProcessRequest:(NSURLRequest *)request {
|
||||
if ([[self class] isEqual:[AFHTTPRequestOperation class]]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return [[self acceptableContentTypes] intersectsSet:AFContentTypesFromHTTPHeader([request valueForHTTPHeaderField:@"Accept"])];
|
||||
}
|
||||
|
||||
#pragma mark - NSURLConnectionDelegate
|
||||
|
||||
- (void)connection:(__unused NSURLConnection *)connection
|
||||
didReceiveResponse:(NSURLResponse *)response
|
||||
{
|
||||
self.response = (NSHTTPURLResponse *)response;
|
||||
|
||||
// Set Content-Range header if status code of response is 206 (Partial Content)
|
||||
// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.7
|
||||
long long totalContentLength = self.response.expectedContentLength;
|
||||
long long fileOffset = 0;
|
||||
NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200;
|
||||
if (statusCode == 206) {
|
||||
NSString *contentRange = [self.response.allHeaderFields valueForKey:@"Content-Range"];
|
||||
if ([contentRange hasPrefix:@"bytes"]) {
|
||||
NSArray *byteRanges = [contentRange componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" -/"]];
|
||||
if ([byteRanges count] == 4) {
|
||||
fileOffset = [[byteRanges objectAtIndex:1] longLongValue];
|
||||
totalContentLength = [[byteRanges objectAtIndex:2] longLongValue] ?: -1; // if this is "*", it's converted to 0, but -1 is default.
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) {
|
||||
[self.outputStream setProperty:[NSNumber numberWithInteger:0] forKey:NSStreamFileCurrentOffsetKey];
|
||||
} else {
|
||||
if ([[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length] > 0) {
|
||||
self.outputStream = [NSOutputStream outputStreamToMemory];
|
||||
|
||||
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
|
||||
for (NSString *runLoopMode in self.runLoopModes) {
|
||||
[self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.offsetContentLength = MAX(fileOffset, 0);
|
||||
self.totalContentLength = totalContentLength;
|
||||
|
||||
[self.outputStream open];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,108 @@
|
||||
// AFImageRequestOperation.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>
|
||||
#import "AFHTTPRequestOperation.h"
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
#import <UIKit/UIKit.h>
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
`AFImageRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading an processing images.
|
||||
|
||||
## Acceptable Content Types
|
||||
|
||||
By default, `AFImageRequestOperation` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage:
|
||||
|
||||
- `image/tiff`
|
||||
- `image/jpeg`
|
||||
- `image/gif`
|
||||
- `image/png`
|
||||
- `image/ico`
|
||||
- `image/x-icon`
|
||||
- `image/bmp`
|
||||
- `image/x-bmp`
|
||||
- `image/x-xbitmap`
|
||||
- `image/x-win-bitmap`
|
||||
*/
|
||||
@interface AFImageRequestOperation : AFHTTPRequestOperation
|
||||
|
||||
/**
|
||||
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 defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
@property (readonly, nonatomic, strong) UIImage *responseImage;
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
@property (readonly, nonatomic, strong) NSImage *responseImage;
|
||||
#endif
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
/**
|
||||
The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance.
|
||||
*/
|
||||
@property (nonatomic, assign) CGFloat imageScale;
|
||||
#endif
|
||||
|
||||
/**
|
||||
Creates and returns an `AFImageRequestOperation` object and sets the specified success callback.
|
||||
|
||||
@param urlRequest The request object to be loaded asynchronously during execution of the operation.
|
||||
@param success A block object to be executed when the request finishes successfully. This block has no return value and takes a single arguments, the image created from the response data of the request.
|
||||
|
||||
@return A new image request operation
|
||||
*/
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(UIImage *image))success;
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(NSImage *image))success;
|
||||
#endif
|
||||
|
||||
/**
|
||||
Creates and returns an `AFImageRequestOperation` object and sets the specified success callback.
|
||||
|
||||
@param urlRequest The request object to be loaded asynchronously during execution of the operation.
|
||||
@param imageProcessingBlock A block object to be executed after the image request finishes successfully, but before the image is returned in the `success` block. This block takes a single argument, the image loaded from the response body, and returns the processed image.
|
||||
@param success A block object to be executed when the request finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the image created from the response data.
|
||||
@param failure A block object to be executed when the request finishes unsuccessfully. This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the error associated with the cause for the unsuccessful operation.
|
||||
|
||||
@return A new image request operation
|
||||
*/
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
imageProcessingBlock:(UIImage *(^)(UIImage *image))imageProcessingBlock
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
imageProcessingBlock:(NSImage *(^)(NSImage *image))imageProcessingBlock
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,233 @@
|
||||
// AFImageRequestOperation.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 "AFImageRequestOperation.h"
|
||||
|
||||
static dispatch_queue_t af_image_request_operation_processing_queue;
|
||||
static dispatch_queue_t image_request_operation_processing_queue() {
|
||||
if (af_image_request_operation_processing_queue == NULL) {
|
||||
af_image_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.image-request.processing", 0);
|
||||
}
|
||||
|
||||
return af_image_request_operation_processing_queue;
|
||||
}
|
||||
|
||||
@interface AFImageRequestOperation ()
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
@property (readwrite, nonatomic, strong) UIImage *responseImage;
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
@property (readwrite, nonatomic, strong) NSImage *responseImage;
|
||||
#endif
|
||||
@end
|
||||
|
||||
@implementation AFImageRequestOperation
|
||||
@synthesize responseImage = _responseImage;
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
@synthesize imageScale = _imageScale;
|
||||
#endif
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(UIImage *image))success
|
||||
{
|
||||
return [self imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil success:^(NSURLRequest __unused *request, NSHTTPURLResponse __unused *response, UIImage *image) {
|
||||
if (success) {
|
||||
success(image);
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(NSImage *image))success
|
||||
{
|
||||
return [self imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil success:^(NSURLRequest __unused *request, NSHTTPURLResponse __unused *response, NSImage *image) {
|
||||
if (success) {
|
||||
success(image);
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
|
||||
{
|
||||
AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
|
||||
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||
if (success) {
|
||||
UIImage *image = responseObject;
|
||||
if (imageProcessingBlock) {
|
||||
dispatch_async(image_request_operation_processing_queue(), ^(void) {
|
||||
UIImage *processedImage = imageProcessingBlock(image);
|
||||
|
||||
dispatch_async(operation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) {
|
||||
success(operation.request, operation.response, processedImage);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
success(operation.request, operation.response, image);
|
||||
}
|
||||
}
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if (failure) {
|
||||
failure(operation.request, operation.response, error);
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
return requestOperation;
|
||||
}
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
imageProcessingBlock:(NSImage *(^)(NSImage *))imageProcessingBlock
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
|
||||
{
|
||||
AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
|
||||
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||
if (success) {
|
||||
NSImage *image = responseObject;
|
||||
if (imageProcessingBlock) {
|
||||
dispatch_async(image_request_operation_processing_queue(), ^(void) {
|
||||
NSImage *processedImage = imageProcessingBlock(image);
|
||||
|
||||
dispatch_async(operation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) {
|
||||
success(operation.request, operation.response, processedImage);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
success(operation.request, operation.response, image);
|
||||
}
|
||||
}
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if (failure) {
|
||||
failure(operation.request, operation.response, error);
|
||||
}
|
||||
}];
|
||||
|
||||
return requestOperation;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (id)initWithRequest:(NSURLRequest *)urlRequest {
|
||||
self = [super initWithRequest:urlRequest];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
self.imageScale = [[UIScreen mainScreen] scale];
|
||||
#endif
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
- (UIImage *)responseImage {
|
||||
if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) {
|
||||
UIImage *image = [UIImage imageWithData:self.responseData];
|
||||
|
||||
self.responseImage = [UIImage imageWithCGImage:[image CGImage] scale:self.imageScale orientation:image.imageOrientation];
|
||||
}
|
||||
|
||||
return _responseImage;
|
||||
}
|
||||
|
||||
- (void)setImageScale:(CGFloat)imageScale {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wfloat-equal"
|
||||
if (imageScale == _imageScale) {
|
||||
return;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
_imageScale = imageScale;
|
||||
|
||||
self.responseImage = nil;
|
||||
}
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
- (NSImage *)responseImage {
|
||||
if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) {
|
||||
// Ensure that the image is set to it's correct pixel width and height
|
||||
NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:self.responseData];
|
||||
self.responseImage = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])];
|
||||
[self.responseImage addRepresentation:bitimage];
|
||||
}
|
||||
|
||||
return _responseImage;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma mark - AFHTTPRequestOperation
|
||||
|
||||
+ (NSSet *)acceptableContentTypes {
|
||||
return [NSSet setWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil];
|
||||
}
|
||||
|
||||
+ (BOOL)canProcessRequest:(NSURLRequest *)request {
|
||||
static NSSet * _acceptablePathExtension = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_acceptablePathExtension = [[NSSet alloc] initWithObjects:@"tif", @"tiff", @"jpg", @"jpeg", @"gif", @"png", @"ico", @"bmp", @"cur", nil];
|
||||
});
|
||||
|
||||
return [_acceptablePathExtension containsObject:[[request URL] pathExtension]] || [super canProcessRequest:request];
|
||||
}
|
||||
|
||||
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
self.completionBlock = ^ {
|
||||
dispatch_async(image_request_operation_processing_queue(), ^(void) {
|
||||
if (self.error) {
|
||||
if (failure) {
|
||||
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
failure(self, self.error);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (success) {
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
UIImage *image = nil;
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
NSImage *image = nil;
|
||||
#endif
|
||||
|
||||
image = self.responseImage;
|
||||
|
||||
dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
success(self, image);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,71 @@
|
||||
// AFJSONRequestOperation.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>
|
||||
#import "AFHTTPRequestOperation.h"
|
||||
|
||||
/**
|
||||
`AFJSONRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and working with JSON response data.
|
||||
|
||||
## Acceptable Content Types
|
||||
|
||||
By default, `AFJSONRequestOperation` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types:
|
||||
|
||||
- `application/json`
|
||||
- `text/json`
|
||||
|
||||
@warning JSON parsing will use the built-in `NSJSONSerialization` class.
|
||||
*/
|
||||
@interface AFJSONRequestOperation : AFHTTPRequestOperation
|
||||
|
||||
///----------------------------
|
||||
/// @name Getting Response Data
|
||||
///----------------------------
|
||||
|
||||
/**
|
||||
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, strong) id responseJSON;
|
||||
|
||||
/**
|
||||
Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions".
|
||||
*/
|
||||
@property (nonatomic, assign) NSJSONReadingOptions JSONReadingOptions;
|
||||
|
||||
///----------------------------------
|
||||
/// @name Creating Request Operations
|
||||
///----------------------------------
|
||||
|
||||
/**
|
||||
Creates and returns an `AFJSONRequestOperation` object and sets the specified success and failure callbacks.
|
||||
|
||||
@param urlRequest The request object to be loaded asynchronously during execution of the operation
|
||||
@param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the JSON object created from the response data of request.
|
||||
@param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data as JSON. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network or parsing error that occurred.
|
||||
|
||||
@return A new JSON request operation
|
||||
*/
|
||||
+ (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,137 @@
|
||||
// AFJSONRequestOperation.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 "AFJSONRequestOperation.h"
|
||||
|
||||
static dispatch_queue_t af_json_request_operation_processing_queue;
|
||||
static dispatch_queue_t json_request_operation_processing_queue() {
|
||||
if (af_json_request_operation_processing_queue == NULL) {
|
||||
af_json_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.json-request.processing", 0);
|
||||
}
|
||||
|
||||
return af_json_request_operation_processing_queue;
|
||||
}
|
||||
|
||||
@interface AFJSONRequestOperation ()
|
||||
@property (readwrite, nonatomic, strong) id responseJSON;
|
||||
@property (readwrite, nonatomic, strong) NSError *JSONError;
|
||||
@end
|
||||
|
||||
@implementation AFJSONRequestOperation
|
||||
@synthesize responseJSON = _responseJSON;
|
||||
@synthesize JSONReadingOptions = _JSONReadingOptions;
|
||||
@synthesize JSONError = _JSONError;
|
||||
|
||||
+ (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure
|
||||
{
|
||||
AFJSONRequestOperation *requestOperation = [(AFJSONRequestOperation *)[self alloc] initWithRequest:urlRequest];
|
||||
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||
if (success) {
|
||||
success(operation.request, operation.response, responseObject);
|
||||
}
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if (failure) {
|
||||
failure(operation.request, operation.response, error, [(AFJSONRequestOperation *)operation responseJSON]);
|
||||
}
|
||||
}];
|
||||
|
||||
return requestOperation;
|
||||
}
|
||||
|
||||
|
||||
- (id)responseJSON {
|
||||
if (!_responseJSON && [self.responseData length] > 0 && [self isFinished] && !self.JSONError) {
|
||||
NSError *error = nil;
|
||||
|
||||
// Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization.
|
||||
// See https://github.com/rails/rails/issues/1742
|
||||
if ([self.responseData length] == 0 || [self.responseString isEqualToString:@" "]) {
|
||||
self.responseJSON = nil;
|
||||
} else {
|
||||
// Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character
|
||||
// See http://stackoverflow.com/a/12843465/157142
|
||||
NSData *JSONData = [self.responseString dataUsingEncoding:self.responseStringEncoding];
|
||||
self.responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:self.JSONReadingOptions error:&error];
|
||||
}
|
||||
|
||||
self.JSONError = error;
|
||||
}
|
||||
|
||||
return _responseJSON;
|
||||
}
|
||||
|
||||
- (NSError *)error {
|
||||
if (_JSONError) {
|
||||
return _JSONError;
|
||||
} else {
|
||||
return [super error];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - AFHTTPRequestOperation
|
||||
|
||||
+ (NSSet *)acceptableContentTypes {
|
||||
return [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
|
||||
}
|
||||
|
||||
+ (BOOL)canProcessRequest:(NSURLRequest *)request {
|
||||
return [[[request URL] pathExtension] isEqualToString:@"json"] || [super canProcessRequest:request];
|
||||
}
|
||||
|
||||
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
self.completionBlock = ^ {
|
||||
if (self.error) {
|
||||
if (failure) {
|
||||
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
failure(self, self.error);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
dispatch_async(json_request_operation_processing_queue(), ^{
|
||||
id JSON = self.responseJSON;
|
||||
|
||||
if (self.JSONError) {
|
||||
if (failure) {
|
||||
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
failure(self, self.error);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (success) {
|
||||
dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
success(self, JSON);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,75 @@
|
||||
// AFNetworkActivityIndicatorManager.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>
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
`AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
|
||||
|
||||
You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code:
|
||||
|
||||
[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
|
||||
|
||||
By setting `isNetworkActivityIndicatorVisible` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself.
|
||||
|
||||
See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information:
|
||||
http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44
|
||||
*/
|
||||
@interface AFNetworkActivityIndicatorManager : NSObject
|
||||
|
||||
/**
|
||||
A Boolean value indicating whether the manager is enabled.
|
||||
|
||||
@discussion If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.
|
||||
*/
|
||||
@property (nonatomic, assign, getter = isEnabled) BOOL enabled;
|
||||
|
||||
/**
|
||||
A Boolean value indicating whether the network activity indicator is currently displayed in the status bar.
|
||||
*/
|
||||
@property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible;
|
||||
|
||||
/**
|
||||
Returns the shared network activity indicator manager object for the system.
|
||||
|
||||
@return The systemwide network activity indicator manager.
|
||||
*/
|
||||
+ (instancetype)sharedManager;
|
||||
|
||||
/**
|
||||
Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.
|
||||
*/
|
||||
- (void)incrementActivityCount;
|
||||
|
||||
/**
|
||||
Decrements the number of active network requests. If this number becomes zero before decrementing, this will stop animating the status bar network activity indicator.
|
||||
*/
|
||||
- (void)decrementActivityCount;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,131 @@
|
||||
// AFNetworkActivityIndicatorManager.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 "AFNetworkActivityIndicatorManager.h"
|
||||
|
||||
#import "AFHTTPRequestOperation.h"
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17;
|
||||
|
||||
@interface AFNetworkActivityIndicatorManager ()
|
||||
@property (readwrite, assign) NSInteger activityCount;
|
||||
@property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer;
|
||||
@property (readonly, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
|
||||
|
||||
- (void)updateNetworkActivityIndicatorVisibility;
|
||||
- (void)updateNetworkActivityIndicatorVisibilityDelayed;
|
||||
@end
|
||||
|
||||
@implementation AFNetworkActivityIndicatorManager
|
||||
@synthesize activityCount = _activityCount;
|
||||
@synthesize activityIndicatorVisibilityTimer = _activityIndicatorVisibilityTimer;
|
||||
@synthesize enabled = _enabled;
|
||||
@dynamic networkActivityIndicatorVisible;
|
||||
|
||||
+ (instancetype)sharedManager {
|
||||
static AFNetworkActivityIndicatorManager *_sharedManager = nil;
|
||||
static dispatch_once_t oncePredicate;
|
||||
dispatch_once(&oncePredicate, ^{
|
||||
_sharedManager = [[self alloc] init];
|
||||
});
|
||||
|
||||
return _sharedManager;
|
||||
}
|
||||
|
||||
+ (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible {
|
||||
return [NSSet setWithObject:@"activityCount"];
|
||||
}
|
||||
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(incrementActivityCount) name:AFNetworkingOperationDidStartNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(decrementActivityCount) name:AFNetworkingOperationDidFinishNotification object:nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
[_activityIndicatorVisibilityTimer invalidate];
|
||||
|
||||
}
|
||||
|
||||
- (void)updateNetworkActivityIndicatorVisibilityDelayed {
|
||||
if (self.enabled) {
|
||||
// Delay hiding of activity indicator for a short interval, to avoid flickering
|
||||
if (![self isNetworkActivityIndicatorVisible]) {
|
||||
[self.activityIndicatorVisibilityTimer invalidate];
|
||||
self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO];
|
||||
[[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes];
|
||||
} else {
|
||||
[self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isNetworkActivityIndicatorVisible {
|
||||
return _activityCount > 0;
|
||||
}
|
||||
|
||||
- (void)updateNetworkActivityIndicatorVisibility {
|
||||
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]];
|
||||
}
|
||||
|
||||
// Not exposed, but used if activityCount is set via KVC.
|
||||
- (NSInteger)activityCount {
|
||||
return _activityCount;
|
||||
}
|
||||
|
||||
- (void)setActivityCount:(NSInteger)activityCount {
|
||||
@synchronized(self) {
|
||||
_activityCount = activityCount;
|
||||
}
|
||||
[self updateNetworkActivityIndicatorVisibilityDelayed];
|
||||
}
|
||||
|
||||
- (void)incrementActivityCount {
|
||||
[self willChangeValueForKey:@"activityCount"];
|
||||
@synchronized(self) {
|
||||
_activityCount++;
|
||||
}
|
||||
[self didChangeValueForKey:@"activityCount"];
|
||||
[self updateNetworkActivityIndicatorVisibilityDelayed];
|
||||
}
|
||||
|
||||
- (void)decrementActivityCount {
|
||||
[self willChangeValueForKey:@"activityCount"];
|
||||
@synchronized(self) {
|
||||
_activityCount = MAX(_activityCount - 1, 0);
|
||||
}
|
||||
[self didChangeValueForKey:@"activityCount"];
|
||||
[self updateNetworkActivityIndicatorVisibilityDelayed];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
// AFNetworking.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>
|
||||
#import <Availability.h>
|
||||
|
||||
#ifndef _AFNETWORKING_
|
||||
#define _AFNETWORKING_
|
||||
|
||||
#import "AFURLConnectionOperation.h"
|
||||
|
||||
#import "AFHTTPRequestOperation.h"
|
||||
#import "AFJSONRequestOperation.h"
|
||||
#import "AFXMLRequestOperation.h"
|
||||
#import "AFPropertyListRequestOperation.h"
|
||||
#import "AFHTTPClient.h"
|
||||
|
||||
#import "AFImageRequestOperation.h"
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
#import "AFNetworkActivityIndicatorManager.h"
|
||||
#import "UIImageView+AFNetworking.h"
|
||||
#endif
|
||||
#endif /* _AFNETWORKING_ */
|
||||
@@ -0,0 +1,68 @@
|
||||
// AFPropertyListRequestOperation.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>
|
||||
#import "AFHTTPRequestOperation.h"
|
||||
|
||||
/**
|
||||
`AFPropertyListRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and deserializing objects with property list (plist) response data.
|
||||
|
||||
## Acceptable Content Types
|
||||
|
||||
By default, `AFPropertyListRequestOperation` accepts the following MIME types:
|
||||
|
||||
- `application/x-plist`
|
||||
*/
|
||||
@interface AFPropertyListRequestOperation : AFHTTPRequestOperation
|
||||
|
||||
///----------------------------
|
||||
/// @name Getting Response Data
|
||||
///----------------------------
|
||||
|
||||
/**
|
||||
An object deserialized from a plist constructed using the response data.
|
||||
*/
|
||||
@property (readonly, nonatomic) id responsePropertyList;
|
||||
|
||||
///--------------------------------------
|
||||
/// @name Managing Property List Behavior
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
One of the `NSPropertyListMutabilityOptions` options, specifying the mutability of objects deserialized from the property list. By default, this is `NSPropertyListImmutable`.
|
||||
*/
|
||||
@property (nonatomic, assign) NSPropertyListReadOptions propertyListReadOptions;
|
||||
|
||||
/**
|
||||
Creates and returns an `AFPropertyListRequestOperation` object and sets the specified success and failure callbacks.
|
||||
|
||||
@param urlRequest The request object to be loaded asynchronously during execution of the operation
|
||||
@param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the object deserialized from a plist constructed using the response data.
|
||||
@param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while deserializing the object from a property list. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network or parsing error that occurred.
|
||||
|
||||
@return A new property list request operation
|
||||
*/
|
||||
+ (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,141 @@
|
||||
// AFPropertyListRequestOperation.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 "AFPropertyListRequestOperation.h"
|
||||
|
||||
static dispatch_queue_t af_property_list_request_operation_processing_queue;
|
||||
static dispatch_queue_t property_list_request_operation_processing_queue() {
|
||||
if (af_property_list_request_operation_processing_queue == NULL) {
|
||||
af_property_list_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.property-list-request.processing", 0);
|
||||
}
|
||||
|
||||
return af_property_list_request_operation_processing_queue;
|
||||
}
|
||||
|
||||
@interface AFPropertyListRequestOperation ()
|
||||
@property (readwrite, nonatomic) id responsePropertyList;
|
||||
@property (readwrite, nonatomic, assign) NSPropertyListFormat propertyListFormat;
|
||||
@property (readwrite, nonatomic) NSError *propertyListError;
|
||||
@end
|
||||
|
||||
@implementation AFPropertyListRequestOperation
|
||||
@synthesize responsePropertyList = _responsePropertyList;
|
||||
@synthesize propertyListReadOptions = _propertyListReadOptions;
|
||||
@synthesize propertyListFormat = _propertyListFormat;
|
||||
@synthesize propertyListError = _propertyListError;
|
||||
|
||||
+ (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)request
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure
|
||||
{
|
||||
AFPropertyListRequestOperation *requestOperation = [(AFPropertyListRequestOperation *)[self alloc] initWithRequest:request];
|
||||
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||
if (success) {
|
||||
success(operation.request, operation.response, responseObject);
|
||||
}
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if (failure) {
|
||||
failure(operation.request, operation.response, error, [(AFPropertyListRequestOperation *)operation responsePropertyList]);
|
||||
}
|
||||
}];
|
||||
|
||||
return requestOperation;
|
||||
}
|
||||
|
||||
- (id)initWithRequest:(NSURLRequest *)urlRequest {
|
||||
self = [super initWithRequest:urlRequest];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.propertyListReadOptions = NSPropertyListImmutable;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (id)responsePropertyList {
|
||||
if (!_responsePropertyList && [self.responseData length] > 0 && [self isFinished]) {
|
||||
NSPropertyListFormat format;
|
||||
NSError *error = nil;
|
||||
self.responsePropertyList = [NSPropertyListSerialization propertyListWithData:self.responseData options:self.propertyListReadOptions format:&format error:&error];
|
||||
self.propertyListFormat = format;
|
||||
self.propertyListError = error;
|
||||
}
|
||||
|
||||
return _responsePropertyList;
|
||||
}
|
||||
|
||||
- (NSError *)error {
|
||||
if (_propertyListError) {
|
||||
return _propertyListError;
|
||||
} else {
|
||||
return [super error];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - AFHTTPRequestOperation
|
||||
|
||||
+ (NSSet *)acceptableContentTypes {
|
||||
return [NSSet setWithObjects:@"application/x-plist", nil];
|
||||
}
|
||||
|
||||
+ (BOOL)canProcessRequest:(NSURLRequest *)request {
|
||||
return [[[request URL] pathExtension] isEqualToString:@"plist"] || [super canProcessRequest:request];
|
||||
}
|
||||
|
||||
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
self.completionBlock = ^ {
|
||||
if (self.error) {
|
||||
if (failure) {
|
||||
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
failure(self, self.error);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
dispatch_async(property_list_request_operation_processing_queue(), ^(void) {
|
||||
id propertyList = self.responsePropertyList;
|
||||
|
||||
if (self.propertyListError) {
|
||||
if (failure) {
|
||||
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
failure(self, self.error);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (success) {
|
||||
dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
success(self, propertyList);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,309 @@
|
||||
// AFURLConnectionOperation.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>
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
/**
|
||||
`AFURLConnectionOperation` is a subclass of `NSOperation` that implements `NSURLConnection` delegate methods.
|
||||
|
||||
## Subclassing Notes
|
||||
|
||||
This is the base class of all network request operations. You may wish to create your own subclass in order to implement additional `NSURLConnection` delegate methods (see "`NSURLConnection` Delegate Methods" below), or to provide additional properties and/or class constructors.
|
||||
|
||||
If you are creating a subclass that communicates over the HTTP or HTTPS protocols, you may want to consider subclassing `AFHTTPRequestOperation` instead, as it supports specifying acceptable content types or status codes.
|
||||
|
||||
## NSURLConnection Delegate Methods
|
||||
|
||||
`AFURLConnectionOperation` implements the following `NSURLConnection` delegate methods:
|
||||
|
||||
- `connection:didReceiveResponse:`
|
||||
- `connection:didReceiveData:`
|
||||
- `connectionDidFinishLoading:`
|
||||
- `connection:didFailWithError:`
|
||||
- `connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:`
|
||||
- `connection:willCacheResponse:`
|
||||
- `connection:canAuthenticateAgainstProtectionSpace:`
|
||||
- `connection:didReceiveAuthenticationChallenge:`
|
||||
|
||||
If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first.
|
||||
|
||||
## Class Constructors
|
||||
|
||||
Class constructors, or methods that return an unowned instance, are the preferred way for subclasses to encapsulate any particular logic for handling the setup or parsing of response data. For instance, `AFJSONRequestOperation` provides `JSONRequestOperationWithRequest:success:failure:`, which takes block arguments, whose parameter on for a successful request is the JSON object initialized from the `response data`.
|
||||
|
||||
## Callbacks and Completion Blocks
|
||||
|
||||
The built-in `completionBlock` provided by `NSOperation` allows for custom behavior to be executed after the request finishes. It is a common pattern for class constructors in subclasses to take callback block parameters, and execute them conditionally in the body of its `completionBlock`. Make sure to handle cancelled operations appropriately when setting a `completionBlock` (i.e. returning early before parsing response data). See the implementation of any of the `AFHTTPRequestOperation` subclasses for an example of this.
|
||||
|
||||
Subclasses are strongly discouraged from overriding `setCompletionBlock:`, as `AFURLConnectionOperation`'s implementation includes a workaround to mitigate retain cycles, and what Apple rather ominously refers to as ["The Deallocation Problem"](http://developer.apple.com/library/ios/#technotes/tn2109/).
|
||||
|
||||
## NSCoding & NSCopying Conformance
|
||||
|
||||
`AFURLConnectionOperation` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. However, because of the intrinsic limitations of capturing the exact state of an operation at a particular moment, there are some important caveats to keep in mind:
|
||||
|
||||
### NSCoding Caveats
|
||||
|
||||
- Encoded operations do not include any block or stream properties. Be sure to set `completionBlock`, `outputStream`, and any callback blocks as necessary when using `-initWithCoder:` or `NSKeyedUnarchiver`.
|
||||
- Operations are paused on `encodeWithCoder:`. If the operation was encoded while paused or still executing, its archived state will return `YES` for `isReady`. Otherwise, the state of an operation when encoding will remain unchanged.
|
||||
|
||||
### NSCopying Caveats
|
||||
|
||||
- `-copy` and `-copyWithZone:` return a new operation with the `NSURLRequest` of the original. So rather than an exact copy of the operation at that particular instant, the copying mechanism returns a completely new instance, which can be useful for retrying operations.
|
||||
- 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 would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied.
|
||||
*/
|
||||
@interface AFURLConnectionOperation : NSOperation <NSURLConnectionDelegate, NSURLConnectionDataDelegate, NSCoding, NSCopying>
|
||||
|
||||
///-------------------------------
|
||||
/// @name Accessing Run Loop Modes
|
||||
///-------------------------------
|
||||
|
||||
/**
|
||||
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, strong) NSSet *runLoopModes;
|
||||
|
||||
///-----------------------------------------
|
||||
/// @name Getting URL Connection Information
|
||||
///-----------------------------------------
|
||||
|
||||
/**
|
||||
The request used by the operation's connection.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSURLRequest *request;
|
||||
|
||||
/**
|
||||
The last response received by the operation's connection.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSURLResponse *response;
|
||||
|
||||
/**
|
||||
The error, if any, that occurred in the lifecycle of the request.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSError *error;
|
||||
|
||||
///----------------------------
|
||||
/// @name Getting Response Data
|
||||
///----------------------------
|
||||
|
||||
/**
|
||||
The data received during the request.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSData *responseData;
|
||||
|
||||
/**
|
||||
The string representation of the response data.
|
||||
*/
|
||||
@property (readonly, nonatomic, copy) NSString *responseString;
|
||||
|
||||
/**
|
||||
The string encoding of the response.
|
||||
|
||||
@discussion If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`.
|
||||
*/
|
||||
@property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding;
|
||||
|
||||
///------------------------
|
||||
/// @name Accessing Streams
|
||||
///------------------------
|
||||
|
||||
/**
|
||||
The input stream used to read data to be sent during the request.
|
||||
|
||||
@discussion This property acts as a proxy to the `HTTPBodyStream` property of `request`.
|
||||
*/
|
||||
@property (nonatomic, strong) NSInputStream *inputStream;
|
||||
|
||||
/**
|
||||
The output stream that is used to write data received until the request is finished.
|
||||
|
||||
@discussion By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set.
|
||||
*/
|
||||
@property (nonatomic, strong) NSOutputStream *outputStream;
|
||||
|
||||
///---------------------------------------------
|
||||
/// @name Managing Request Operation Information
|
||||
///---------------------------------------------
|
||||
|
||||
/**
|
||||
The user info dictionary for the receiver.
|
||||
*/
|
||||
@property (nonatomic, strong) NSDictionary *userInfo;
|
||||
|
||||
///------------------------------------------------------
|
||||
/// @name Initializing an AFURLConnectionOperation Object
|
||||
///------------------------------------------------------
|
||||
|
||||
/**
|
||||
Initializes and returns a newly allocated operation object with a url connection configured with the specified url request.
|
||||
|
||||
@param urlRequest The request object to be used by the operation connection.
|
||||
|
||||
@discussion This is the designated initializer.
|
||||
*/
|
||||
- (id)initWithRequest:(NSURLRequest *)urlRequest;
|
||||
|
||||
///----------------------------------
|
||||
/// @name Pausing / Resuming Requests
|
||||
///----------------------------------
|
||||
|
||||
/**
|
||||
Pauses the execution of the request operation.
|
||||
|
||||
@discussion A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect.
|
||||
*/
|
||||
- (void)pause;
|
||||
|
||||
/**
|
||||
Whether the request operation is currently paused.
|
||||
|
||||
@return `YES` if the operation is currently paused, otherwise `NO`.
|
||||
*/
|
||||
- (BOOL)isPaused;
|
||||
|
||||
/**
|
||||
Resumes the execution of the paused request operation.
|
||||
|
||||
@discussion Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request.
|
||||
*/
|
||||
- (void)resume;
|
||||
|
||||
///----------------------------------------------
|
||||
/// @name Configuring Backgrounding Task Behavior
|
||||
///----------------------------------------------
|
||||
|
||||
/**
|
||||
Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task.
|
||||
|
||||
@param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified.
|
||||
*/
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler;
|
||||
#endif
|
||||
|
||||
///---------------------------------
|
||||
/// @name Setting Progress Callbacks
|
||||
///---------------------------------
|
||||
|
||||
/**
|
||||
Sets a callback to be called when an undetermined number of bytes have been uploaded to the server.
|
||||
|
||||
@param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread.
|
||||
*/
|
||||
- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block;
|
||||
|
||||
/**
|
||||
Sets a callback to be called when an undetermined number of bytes have been downloaded from the server.
|
||||
|
||||
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread.
|
||||
*/
|
||||
- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block;
|
||||
|
||||
///-------------------------------------------------
|
||||
/// @name Setting NSURLConnection Delegate Callbacks
|
||||
///-------------------------------------------------
|
||||
|
||||
/**
|
||||
Sets a block to be executed to determine whether the connection should be able to respond to a protection space's form of authentication, as handled by the `NSURLConnectionDelegate` method `connection:canAuthenticateAgainstProtectionSpace:`.
|
||||
|
||||
@param block A block object to be executed to determine whether the connection should be able to respond to a protection space's form of authentication. The block has a `BOOL` return type and takes two arguments: the URL connection object, and the protection space to authenticate against.
|
||||
|
||||
@discussion If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`.
|
||||
*/
|
||||
- (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed when the connection must authenticate a challenge in order to download its request, as handled by the `NSURLConnectionDelegate` method `connection:didReceiveAuthenticationChallenge:`.
|
||||
|
||||
@param block A block object to be executed when the connection must authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated.
|
||||
|
||||
@discussion If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates.
|
||||
*/
|
||||
- (void)setAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed when the server redirects the request from one URL to another URL, or when the request URL changed by the `NSURLProtocol` subclass handling the request in order to standardize its format, as handled by the `NSURLConnectionDelegate` method `connection:willSendRequest:redirectResponse:`.
|
||||
|
||||
@param block A block object to be executed when the request URL was changed. The block returns an `NSURLRequest` object, the URL request to redirect, and takes three arguments: the URL connection object, the the proposed redirected request, and the URL response that caused the redirect.
|
||||
*/
|
||||
- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block;
|
||||
|
||||
|
||||
/**
|
||||
Sets a block to be executed to modify the response a connection will cache, if any, as handled by the `NSURLConnectionDelegate` method `connection:willCacheResponse:`.
|
||||
|
||||
@param block A block object to be executed to determine what response a connection will cache, if any. The block returns an `NSCachedURLResponse` object, the cached response to store in memory or `nil` to prevent the response from being cached, and takes two arguments: the URL connection object, and the cached response provided for the request.
|
||||
*/
|
||||
- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block;
|
||||
|
||||
@end
|
||||
|
||||
///----------------
|
||||
/// @name Constants
|
||||
///----------------
|
||||
|
||||
/**
|
||||
## User info dictionary keys
|
||||
|
||||
These keys may exist in the user info dictionary, in addition to those defined for NSError.
|
||||
|
||||
- `NSString * const AFNetworkingOperationFailingURLRequestErrorKey`
|
||||
- `NSString * const AFNetworkingOperationFailingURLResponseErrorKey`
|
||||
|
||||
### Constants
|
||||
|
||||
`AFNetworkingOperationFailingURLRequestErrorKey`
|
||||
The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFNetworkingErrorDomain`.
|
||||
|
||||
`AFNetworkingOperationFailingURLResponseErrorKey`
|
||||
The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFNetworkingErrorDomain`.
|
||||
|
||||
## Error Domains
|
||||
|
||||
The following error domain is predefined.
|
||||
|
||||
- `NSString * const AFNetworkingErrorDomain`
|
||||
|
||||
### Constants
|
||||
|
||||
`AFNetworkingErrorDomain`
|
||||
AFNetworking errors. Error codes for `AFNetworkingErrorDomain` correspond to codes in `NSURLErrorDomain`.
|
||||
*/
|
||||
extern NSString * const AFNetworkingErrorDomain;
|
||||
extern NSString * const AFNetworkingOperationFailingURLRequestErrorKey;
|
||||
extern NSString * const AFNetworkingOperationFailingURLResponseErrorKey;
|
||||
|
||||
///--------------------
|
||||
/// @name Notifications
|
||||
///--------------------
|
||||
|
||||
/**
|
||||
Posted when an operation begins executing.
|
||||
*/
|
||||
extern NSString * const AFNetworkingOperationDidStartNotification;
|
||||
|
||||
/**
|
||||
Posted when an operation finishes.
|
||||
*/
|
||||
extern NSString * const AFNetworkingOperationDidFinishNotification;
|
||||
@@ -0,0 +1,712 @@
|
||||
// AFURLConnectionOperation.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 "AFURLConnectionOperation.h"
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
#error AFNetworking must be built with ARC.
|
||||
// You can turn on ARC for only AFNetworking files by adding -fobjc-arc to the build phase for each of its files.
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
AFOperationPausedState = -1,
|
||||
AFOperationReadyState = 1,
|
||||
AFOperationExecutingState = 2,
|
||||
AFOperationFinishedState = 3,
|
||||
} _AFOperationState;
|
||||
|
||||
typedef signed short AFOperationState;
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier;
|
||||
#else
|
||||
typedef id AFBackgroundTaskIdentifier;
|
||||
#endif
|
||||
|
||||
static NSString * const kAFNetworkingLockName = @"com.alamofire.networking.operation.lock";
|
||||
|
||||
NSString * const AFNetworkingErrorDomain = @"AFNetworkingErrorDomain";
|
||||
NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"AFNetworkingOperationFailingURLRequestErrorKey";
|
||||
NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"AFNetworkingOperationFailingURLResponseErrorKey";
|
||||
|
||||
NSString * const AFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start";
|
||||
NSString * const AFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish";
|
||||
|
||||
typedef void (^AFURLConnectionOperationProgressBlock)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected);
|
||||
typedef BOOL (^AFURLConnectionOperationAuthenticationAgainstProtectionSpaceBlock)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace);
|
||||
typedef void (^AFURLConnectionOperationAuthenticationChallengeBlock)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge);
|
||||
typedef NSCachedURLResponse * (^AFURLConnectionOperationCacheResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse);
|
||||
typedef NSURLRequest * (^AFURLConnectionOperationRedirectResponseBlock)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse);
|
||||
|
||||
static inline NSString * AFKeyPathFromOperationState(AFOperationState state) {
|
||||
switch (state) {
|
||||
case AFOperationReadyState:
|
||||
return @"isReady";
|
||||
case AFOperationExecutingState:
|
||||
return @"isExecuting";
|
||||
case AFOperationFinishedState:
|
||||
return @"isFinished";
|
||||
case AFOperationPausedState:
|
||||
return @"isPaused";
|
||||
default:
|
||||
return @"state";
|
||||
}
|
||||
}
|
||||
|
||||
static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperationState toState, BOOL isCancelled) {
|
||||
switch (fromState) {
|
||||
case AFOperationReadyState:
|
||||
switch (toState) {
|
||||
case AFOperationPausedState:
|
||||
case AFOperationExecutingState:
|
||||
return YES;
|
||||
case AFOperationFinishedState:
|
||||
return isCancelled;
|
||||
default:
|
||||
return NO;
|
||||
}
|
||||
case AFOperationExecutingState:
|
||||
switch (toState) {
|
||||
case AFOperationPausedState:
|
||||
case AFOperationFinishedState:
|
||||
return YES;
|
||||
default:
|
||||
return NO;
|
||||
}
|
||||
case AFOperationFinishedState:
|
||||
return NO;
|
||||
case AFOperationPausedState:
|
||||
return toState == AFOperationReadyState;
|
||||
default:
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
@interface AFURLConnectionOperation ()
|
||||
@property (readwrite, nonatomic, assign) AFOperationState state;
|
||||
@property (readwrite, nonatomic, assign, getter = isCancelled) BOOL cancelled;
|
||||
@property (readwrite, nonatomic, strong) NSRecursiveLock *lock;
|
||||
@property (readwrite, nonatomic, strong) NSURLConnection *connection;
|
||||
@property (readwrite, nonatomic, strong) NSURLRequest *request;
|
||||
@property (readwrite, nonatomic, strong) NSURLResponse *response;
|
||||
@property (readwrite, nonatomic, strong) NSError *error;
|
||||
@property (readwrite, nonatomic, strong) NSData *responseData;
|
||||
@property (readwrite, nonatomic, copy) NSString *responseString;
|
||||
@property (readwrite, nonatomic, assign) NSStringEncoding responseStringEncoding;
|
||||
@property (readwrite, nonatomic, assign) long long totalBytesRead;
|
||||
@property (readwrite, nonatomic, assign) AFBackgroundTaskIdentifier backgroundTaskIdentifier;
|
||||
@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress;
|
||||
@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress;
|
||||
@property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationAgainstProtectionSpaceBlock authenticationAgainstProtectionSpace;
|
||||
@property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationChallengeBlock authenticationChallenge;
|
||||
@property (readwrite, nonatomic, copy) AFURLConnectionOperationCacheResponseBlock cacheResponse;
|
||||
@property (readwrite, nonatomic, copy) AFURLConnectionOperationRedirectResponseBlock redirectResponse;
|
||||
|
||||
- (void)operationDidStart;
|
||||
- (void)finish;
|
||||
- (void)cancelConnection;
|
||||
@end
|
||||
|
||||
@implementation AFURLConnectionOperation
|
||||
@synthesize state = _state;
|
||||
@synthesize cancelled = _cancelled;
|
||||
@synthesize connection = _connection;
|
||||
@synthesize runLoopModes = _runLoopModes;
|
||||
@synthesize request = _request;
|
||||
@synthesize response = _response;
|
||||
@synthesize error = _error;
|
||||
@synthesize responseData = _responseData;
|
||||
@synthesize responseString = _responseString;
|
||||
@synthesize responseStringEncoding = _responseStringEncoding;
|
||||
@synthesize totalBytesRead = _totalBytesRead;
|
||||
@dynamic inputStream;
|
||||
@synthesize outputStream = _outputStream;
|
||||
@synthesize userInfo = _userInfo;
|
||||
@synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier;
|
||||
@synthesize uploadProgress = _uploadProgress;
|
||||
@synthesize downloadProgress = _downloadProgress;
|
||||
@synthesize authenticationAgainstProtectionSpace = _authenticationAgainstProtectionSpace;
|
||||
@synthesize authenticationChallenge = _authenticationChallenge;
|
||||
@synthesize cacheResponse = _cacheResponse;
|
||||
@synthesize redirectResponse = _redirectResponse;
|
||||
@synthesize lock = _lock;
|
||||
|
||||
+ (void) __attribute__((noreturn)) networkRequestThreadEntryPoint:(id)__unused object {
|
||||
do {
|
||||
@autoreleasepool {
|
||||
[[NSRunLoop currentRunLoop] run];
|
||||
}
|
||||
} while (YES);
|
||||
}
|
||||
|
||||
+ (NSThread *)networkRequestThread {
|
||||
static NSThread *_networkRequestThread = nil;
|
||||
static dispatch_once_t oncePredicate;
|
||||
|
||||
dispatch_once(&oncePredicate, ^{
|
||||
_networkRequestThread = [[NSThread alloc] initWithTarget:self selector:@selector(networkRequestThreadEntryPoint:) object:nil];
|
||||
[_networkRequestThread start];
|
||||
});
|
||||
|
||||
return _networkRequestThread;
|
||||
}
|
||||
|
||||
+ (NSArray *)pinnedCertificates {
|
||||
static NSArray *_pinnedCertificates = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
||||
NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."];
|
||||
NSMutableArray *certificates = [NSMutableArray array];
|
||||
for (NSString *path in paths) {
|
||||
NSData *certificateData = [NSData dataWithContentsOfFile:path];
|
||||
[certificates addObject:certificateData];
|
||||
}
|
||||
_pinnedCertificates = [[NSArray alloc] initWithArray:certificates];
|
||||
});
|
||||
|
||||
return _pinnedCertificates;
|
||||
}
|
||||
|
||||
- (id)initWithRequest:(NSURLRequest *)urlRequest {
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.lock = [[NSRecursiveLock alloc] init];
|
||||
self.lock.name = kAFNetworkingLockName;
|
||||
|
||||
self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes];
|
||||
|
||||
self.request = urlRequest;
|
||||
|
||||
self.outputStream = [NSOutputStream outputStreamToMemory];
|
||||
|
||||
self.state = AFOperationReadyState;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if (_outputStream) {
|
||||
[_outputStream close];
|
||||
_outputStream = nil;
|
||||
}
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
if (_backgroundTaskIdentifier) {
|
||||
[[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier];
|
||||
_backgroundTaskIdentifier = UIBackgroundTaskInvalid;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString stringWithFormat:@"<%@: %p, state: %@, cancelled: %@ request: %@, response: %@>", NSStringFromClass([self class]), self, AFKeyPathFromOperationState(self.state), ([self isCancelled] ? @"YES" : @"NO"), self.request, self.response];
|
||||
}
|
||||
|
||||
- (void)setCompletionBlock:(void (^)(void))block {
|
||||
[self.lock lock];
|
||||
if (!block) {
|
||||
[super setCompletionBlock:nil];
|
||||
} else {
|
||||
__weak __typeof(&*self)weakSelf = self;
|
||||
[super setCompletionBlock:^ {
|
||||
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
|
||||
|
||||
block();
|
||||
[strongSelf setCompletionBlock:nil];
|
||||
}];
|
||||
}
|
||||
[self.lock unlock];
|
||||
}
|
||||
|
||||
- (NSInputStream *)inputStream {
|
||||
return self.request.HTTPBodyStream;
|
||||
}
|
||||
|
||||
- (void)setInputStream:(NSInputStream *)inputStream {
|
||||
[self willChangeValueForKey:@"inputStream"];
|
||||
NSMutableURLRequest *mutableRequest = [self.request mutableCopy];
|
||||
mutableRequest.HTTPBodyStream = inputStream;
|
||||
self.request = mutableRequest;
|
||||
[self didChangeValueForKey:@"inputStream"];
|
||||
}
|
||||
|
||||
- (void)setOutputStream:(NSOutputStream *)outputStream {
|
||||
if (outputStream == _outputStream) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self willChangeValueForKey:@"outputStream"];
|
||||
if (_outputStream) {
|
||||
[_outputStream close];
|
||||
}
|
||||
_outputStream = outputStream;
|
||||
[self didChangeValueForKey:@"outputStream"];
|
||||
}
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler {
|
||||
[self.lock lock];
|
||||
if (!self.backgroundTaskIdentifier) {
|
||||
UIApplication *application = [UIApplication sharedApplication];
|
||||
__weak __typeof(&*self)weakSelf = self;
|
||||
self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{
|
||||
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
|
||||
|
||||
if (handler) {
|
||||
handler();
|
||||
}
|
||||
|
||||
if (strongSelf) {
|
||||
[strongSelf cancel];
|
||||
|
||||
[application endBackgroundTask:strongSelf.backgroundTaskIdentifier];
|
||||
strongSelf.backgroundTaskIdentifier = UIBackgroundTaskInvalid;
|
||||
}
|
||||
}];
|
||||
}
|
||||
[self.lock unlock];
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block {
|
||||
self.uploadProgress = block;
|
||||
}
|
||||
|
||||
- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block {
|
||||
self.downloadProgress = block;
|
||||
}
|
||||
|
||||
- (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *, NSURLProtectionSpace *))block {
|
||||
self.authenticationAgainstProtectionSpace = block;
|
||||
}
|
||||
|
||||
- (void)setAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block {
|
||||
self.authenticationChallenge = block;
|
||||
}
|
||||
|
||||
- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block {
|
||||
self.cacheResponse = block;
|
||||
}
|
||||
|
||||
- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block {
|
||||
self.redirectResponse = block;
|
||||
}
|
||||
|
||||
- (void)setState:(AFOperationState)state {
|
||||
[self.lock lock];
|
||||
if (AFStateTransitionIsValid(self.state, state, [self isCancelled])) {
|
||||
NSString *oldStateKey = AFKeyPathFromOperationState(self.state);
|
||||
NSString *newStateKey = AFKeyPathFromOperationState(state);
|
||||
|
||||
[self willChangeValueForKey:newStateKey];
|
||||
[self willChangeValueForKey:oldStateKey];
|
||||
_state = state;
|
||||
[self didChangeValueForKey:oldStateKey];
|
||||
[self didChangeValueForKey:newStateKey];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
switch (state) {
|
||||
case AFOperationExecutingState:
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self];
|
||||
break;
|
||||
case AFOperationFinishedState:
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
[self.lock unlock];
|
||||
}
|
||||
|
||||
- (NSString *)responseString {
|
||||
[self.lock lock];
|
||||
if (!_responseString && self.response && self.responseData) {
|
||||
self.responseString = [[NSString alloc] initWithData:self.responseData encoding:self.responseStringEncoding];
|
||||
}
|
||||
[self.lock unlock];
|
||||
|
||||
return _responseString;
|
||||
}
|
||||
|
||||
- (NSStringEncoding)responseStringEncoding {
|
||||
[self.lock lock];
|
||||
if (!_responseStringEncoding) {
|
||||
NSStringEncoding stringEncoding = NSUTF8StringEncoding;
|
||||
if (self.response.textEncodingName) {
|
||||
CFStringEncoding IANAEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName);
|
||||
if (IANAEncoding != kCFStringEncodingInvalidId) {
|
||||
stringEncoding = CFStringConvertEncodingToNSStringEncoding(IANAEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
self.responseStringEncoding = stringEncoding;
|
||||
}
|
||||
[self.lock unlock];
|
||||
|
||||
return _responseStringEncoding;
|
||||
}
|
||||
|
||||
- (void)pause {
|
||||
if ([self isPaused] || [self isFinished] || [self isCancelled]) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self.lock lock];
|
||||
|
||||
if ([self isExecuting]) {
|
||||
[self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
|
||||
});
|
||||
}
|
||||
|
||||
self.state = AFOperationPausedState;
|
||||
|
||||
[self.lock unlock];
|
||||
}
|
||||
|
||||
- (BOOL)isPaused {
|
||||
return self.state == AFOperationPausedState;
|
||||
}
|
||||
|
||||
- (void)resume {
|
||||
if (![self isPaused]) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self.lock lock];
|
||||
self.state = AFOperationReadyState;
|
||||
|
||||
[self start];
|
||||
[self.lock unlock];
|
||||
}
|
||||
|
||||
#pragma mark - NSOperation
|
||||
|
||||
- (BOOL)isReady {
|
||||
return self.state == AFOperationReadyState && [super isReady];
|
||||
}
|
||||
|
||||
- (BOOL)isExecuting {
|
||||
return self.state == AFOperationExecutingState;
|
||||
}
|
||||
|
||||
- (BOOL)isFinished {
|
||||
return self.state == AFOperationFinishedState;
|
||||
}
|
||||
|
||||
- (BOOL)isConcurrent {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)start {
|
||||
[self.lock lock];
|
||||
if ([self isReady]) {
|
||||
self.state = AFOperationExecutingState;
|
||||
|
||||
[self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]];
|
||||
}
|
||||
[self.lock unlock];
|
||||
}
|
||||
|
||||
- (void)operationDidStart {
|
||||
[self.lock lock];
|
||||
if ([self isCancelled]) {
|
||||
[self finish];
|
||||
} else {
|
||||
self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO];
|
||||
|
||||
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
|
||||
for (NSString *runLoopMode in self.runLoopModes) {
|
||||
[self.connection scheduleInRunLoop:runLoop forMode:runLoopMode];
|
||||
[self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode];
|
||||
}
|
||||
|
||||
[self.connection start];
|
||||
}
|
||||
[self.lock unlock];
|
||||
}
|
||||
|
||||
- (void)finish {
|
||||
self.state = AFOperationFinishedState;
|
||||
}
|
||||
|
||||
- (void)cancel {
|
||||
[self.lock lock];
|
||||
if (![self isFinished] && ![self isCancelled]) {
|
||||
[self willChangeValueForKey:@"isCancelled"];
|
||||
_cancelled = YES;
|
||||
[super cancel];
|
||||
[self didChangeValueForKey:@"isCancelled"];
|
||||
|
||||
// Cancel the connection on the thread it runs on to prevent race conditions
|
||||
[self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]];
|
||||
}
|
||||
[self.lock unlock];
|
||||
}
|
||||
|
||||
- (void)cancelConnection {
|
||||
NSDictionary *userInfo = nil;
|
||||
if ([self.request URL]) {
|
||||
userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey];
|
||||
}
|
||||
self.error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo];
|
||||
|
||||
if (self.connection) {
|
||||
[self.connection cancel];
|
||||
|
||||
// Manually send this delegate message since `[self.connection cancel]` causes the connection to never send another message to its delegate
|
||||
[self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.error];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - NSURLConnectionDelegate
|
||||
|
||||
#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_
|
||||
- (void)connection:(NSURLConnection *)connection
|
||||
willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
|
||||
{
|
||||
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
||||
SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
|
||||
SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0);
|
||||
NSData *certificateData = (__bridge_transfer NSData *)SecCertificateCopyData(certificate);
|
||||
|
||||
if ([[[self class] pinnedCertificates] containsObject:certificateData]) {
|
||||
NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust];
|
||||
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
|
||||
} else {
|
||||
[[challenge sender] cancelAuthenticationChallenge:challenge];
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
- (BOOL)connection:(NSURLConnection *)connection
|
||||
canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
|
||||
{
|
||||
#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_
|
||||
if ([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
||||
return YES;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (self.authenticationAgainstProtectionSpace) {
|
||||
return self.authenticationAgainstProtectionSpace(connection, protectionSpace);
|
||||
} else if ([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust] || [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodClientCertificate]) {
|
||||
return NO;
|
||||
} else {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection *)connection
|
||||
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
|
||||
{
|
||||
#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_
|
||||
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
||||
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (self.authenticationChallenge) {
|
||||
self.authenticationChallenge(connection, challenge);
|
||||
} else {
|
||||
if ([challenge previousFailureCount] == 0) {
|
||||
NSURLCredential *credential = nil;
|
||||
|
||||
NSString *username = (__bridge_transfer NSString *)CFURLCopyUserName((__bridge CFURLRef)[self.request URL]);
|
||||
NSString *password = (__bridge_transfer NSString *)CFURLCopyPassword((__bridge CFURLRef)[self.request URL]);
|
||||
|
||||
if (username && password) {
|
||||
credential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceNone];
|
||||
} else if (username) {
|
||||
credential = [[[NSURLCredentialStorage sharedCredentialStorage] credentialsForProtectionSpace:[challenge protectionSpace]] objectForKey:username];
|
||||
} else {
|
||||
credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]];
|
||||
}
|
||||
|
||||
if (credential) {
|
||||
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
|
||||
} else {
|
||||
[[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
|
||||
}
|
||||
} else {
|
||||
[[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSURLRequest *)connection:(NSURLConnection *)connection
|
||||
willSendRequest:(NSURLRequest *)request
|
||||
redirectResponse:(NSURLResponse *)redirectResponse
|
||||
{
|
||||
if (self.redirectResponse) {
|
||||
return self.redirectResponse(connection, request, redirectResponse);
|
||||
} else {
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection __unused *)connection
|
||||
didSendBodyData:(NSInteger)bytesWritten
|
||||
totalBytesWritten:(NSInteger)totalBytesWritten
|
||||
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
|
||||
{
|
||||
if (self.uploadProgress) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.uploadProgress((NSUInteger)bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection __unused *)connection
|
||||
didReceiveResponse:(NSURLResponse *)response
|
||||
{
|
||||
self.response = response;
|
||||
|
||||
[self.outputStream open];
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection __unused *)connection
|
||||
didReceiveData:(NSData *)data
|
||||
{
|
||||
self.totalBytesRead += [data length];
|
||||
|
||||
if ([self.outputStream hasSpaceAvailable]) {
|
||||
const uint8_t *dataBuffer = (uint8_t *) [data bytes];
|
||||
[self.outputStream write:&dataBuffer[0] maxLength:[data length]];
|
||||
}
|
||||
|
||||
if (self.downloadProgress) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.downloadProgress([data length], self.totalBytesRead, self.response.expectedContentLength);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection {
|
||||
self.responseData = [self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
|
||||
[self.outputStream close];
|
||||
|
||||
[self finish];
|
||||
|
||||
self.connection = nil;
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection __unused *)connection
|
||||
didFailWithError:(NSError *)error
|
||||
{
|
||||
self.error = error;
|
||||
|
||||
[self.outputStream close];
|
||||
|
||||
[self finish];
|
||||
|
||||
self.connection = nil;
|
||||
}
|
||||
|
||||
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection
|
||||
willCacheResponse:(NSCachedURLResponse *)cachedResponse
|
||||
{
|
||||
if (self.cacheResponse) {
|
||||
return self.cacheResponse(connection, cachedResponse);
|
||||
} else {
|
||||
if ([self isCancelled]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return cachedResponse;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - NSCoding
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSURLRequest *request = [aDecoder decodeObjectForKey:@"request"];
|
||||
|
||||
self = [self initWithRequest:request];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.state = (AFOperationState)[aDecoder decodeIntegerForKey:@"state"];
|
||||
self.cancelled = [aDecoder decodeBoolForKey:@"isCancelled"];
|
||||
self.response = [aDecoder decodeObjectForKey:@"response"];
|
||||
self.error = [aDecoder decodeObjectForKey:@"error"];
|
||||
self.responseData = [aDecoder decodeObjectForKey:@"responseData"];
|
||||
self.totalBytesRead = [[aDecoder decodeObjectForKey:@"totalBytesRead"] longLongValue];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[self pause];
|
||||
|
||||
[aCoder encodeObject:self.request forKey:@"request"];
|
||||
|
||||
switch (self.state) {
|
||||
case AFOperationExecutingState:
|
||||
case AFOperationPausedState:
|
||||
[aCoder encodeInteger:AFOperationReadyState forKey:@"state"];
|
||||
break;
|
||||
default:
|
||||
[aCoder encodeInteger:self.state forKey:@"state"];
|
||||
break;
|
||||
}
|
||||
|
||||
[aCoder encodeBool:[self isCancelled] forKey:@"isCancelled"];
|
||||
[aCoder encodeObject:self.response forKey:@"response"];
|
||||
[aCoder encodeObject:self.error forKey:@"error"];
|
||||
[aCoder encodeObject:self.responseData forKey:@"responseData"];
|
||||
[aCoder encodeObject:[NSNumber numberWithLongLong:self.totalBytesRead] forKey:@"totalBytesRead"];
|
||||
}
|
||||
|
||||
#pragma mark - NSCopying
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
AFURLConnectionOperation *operation = [(AFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request];
|
||||
|
||||
operation.uploadProgress = self.uploadProgress;
|
||||
operation.downloadProgress = self.downloadProgress;
|
||||
operation.authenticationAgainstProtectionSpace = self.authenticationAgainstProtectionSpace;
|
||||
operation.authenticationChallenge = self.authenticationChallenge;
|
||||
operation.cacheResponse = self.cacheResponse;
|
||||
operation.redirectResponse = self.redirectResponse;
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,89 @@
|
||||
// AFXMLRequestOperation.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>
|
||||
#import "AFHTTPRequestOperation.h"
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
/**
|
||||
`AFXMLRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and working with XML response data.
|
||||
|
||||
## Acceptable Content Types
|
||||
|
||||
By default, `AFXMLRequestOperation` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
|
||||
|
||||
- `application/xml`
|
||||
- `text/xml`
|
||||
|
||||
## Use With AFHTTPClient
|
||||
|
||||
When `AFXMLRequestOperation` is registered with `AFHTTPClient`, the response object in the success callback of `HTTPRequestOperationWithRequest:success:failure:` will be an instance of `NSXMLParser`. On platforms that support `NSXMLDocument`, you have the option to ignore the response object, and simply use the `responseXMLDocument` property of the operation argument of the callback.
|
||||
*/
|
||||
@interface AFXMLRequestOperation : AFHTTPRequestOperation
|
||||
|
||||
///----------------------------
|
||||
/// @name Getting Response Data
|
||||
///----------------------------
|
||||
|
||||
/**
|
||||
An `NSXMLParser` object constructed from the response data.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSXMLParser *responseXMLParser;
|
||||
|
||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
/**
|
||||
An `NSXMLDocument` 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, strong) NSXMLDocument *responseXMLDocument;
|
||||
#endif
|
||||
|
||||
/**
|
||||
Creates and returns an `AFXMLRequestOperation` object and sets the specified success and failure callbacks.
|
||||
|
||||
@param urlRequest The request object to be loaded asynchronously during execution of the operation
|
||||
@param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the XML parser constructed with the response data of request.
|
||||
@param failure A block object to be executed when the operation finishes unsuccessfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network error that occurred.
|
||||
|
||||
@return A new XML request operation
|
||||
*/
|
||||
+ (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure;
|
||||
|
||||
|
||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
/**
|
||||
Creates and returns an `AFXMLRequestOperation` object and sets the specified success and failure callbacks.
|
||||
|
||||
@param urlRequest The request object to be loaded asynchronously during execution of the operation
|
||||
@param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the XML document created from the response data of request.
|
||||
@param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data as XML. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network or parsing error that occurred.
|
||||
|
||||
@return A new XML request operation
|
||||
*/
|
||||
+ (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure;
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,165 @@
|
||||
// AFXMLRequestOperation.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 "AFXMLRequestOperation.h"
|
||||
|
||||
#include <Availability.h>
|
||||
|
||||
static dispatch_queue_t af_xml_request_operation_processing_queue;
|
||||
static dispatch_queue_t xml_request_operation_processing_queue() {
|
||||
if (af_xml_request_operation_processing_queue == NULL) {
|
||||
af_xml_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.xml-request.processing", 0);
|
||||
}
|
||||
|
||||
return af_xml_request_operation_processing_queue;
|
||||
}
|
||||
|
||||
@interface AFXMLRequestOperation ()
|
||||
@property (readwrite, nonatomic, strong) NSXMLParser *responseXMLParser;
|
||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
@property (readwrite, nonatomic, strong) NSXMLDocument *responseXMLDocument;
|
||||
#endif
|
||||
@property (readwrite, nonatomic, strong) NSError *XMLError;
|
||||
@end
|
||||
|
||||
@implementation AFXMLRequestOperation
|
||||
@synthesize responseXMLParser = _responseXMLParser;
|
||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
@synthesize responseXMLDocument = _responseXMLDocument;
|
||||
#endif
|
||||
@synthesize XMLError = _XMLError;
|
||||
|
||||
+ (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure
|
||||
{
|
||||
AFXMLRequestOperation *requestOperation = [(AFXMLRequestOperation *)[self alloc] initWithRequest:urlRequest];
|
||||
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||
if (success) {
|
||||
success(operation.request, operation.response, responseObject);
|
||||
}
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if (failure) {
|
||||
failure(operation.request, operation.response, error, [(AFXMLRequestOperation *)operation responseXMLParser]);
|
||||
}
|
||||
}];
|
||||
|
||||
return requestOperation;
|
||||
}
|
||||
|
||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
+ (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure
|
||||
{
|
||||
AFXMLRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest];
|
||||
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, __unused id responseObject) {
|
||||
if (success) {
|
||||
NSXMLDocument *XMLDocument = [(AFXMLRequestOperation *)operation responseXMLDocument];
|
||||
success(operation.request, operation.response, XMLDocument);
|
||||
}
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if (failure) {
|
||||
NSXMLDocument *XMLDocument = [(AFXMLRequestOperation *)operation responseXMLDocument];
|
||||
failure(operation.request, operation.response, error, XMLDocument);
|
||||
}
|
||||
}];
|
||||
|
||||
return requestOperation;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
- (NSXMLParser *)responseXMLParser {
|
||||
if (!_responseXMLParser && [self.responseData length] > 0 && [self isFinished]) {
|
||||
self.responseXMLParser = [[NSXMLParser alloc] initWithData:self.responseData];
|
||||
}
|
||||
|
||||
return _responseXMLParser;
|
||||
}
|
||||
|
||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
- (NSXMLDocument *)responseXMLDocument {
|
||||
if (!_responseXMLDocument && [self.responseData length] > 0 && [self isFinished]) {
|
||||
NSError *error = nil;
|
||||
self.responseXMLDocument = [[NSXMLDocument alloc] initWithData:self.responseData options:0 error:&error];
|
||||
self.XMLError = error;
|
||||
}
|
||||
|
||||
return _responseXMLDocument;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (NSError *)error {
|
||||
if (_XMLError) {
|
||||
return _XMLError;
|
||||
} else {
|
||||
return [super error];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - NSOperation
|
||||
|
||||
- (void)cancel {
|
||||
[super cancel];
|
||||
|
||||
self.responseXMLParser.delegate = nil;
|
||||
}
|
||||
|
||||
#pragma mark - AFHTTPRequestOperation
|
||||
|
||||
+ (NSSet *)acceptableContentTypes {
|
||||
return [NSSet setWithObjects:@"application/xml", @"text/xml", nil];
|
||||
}
|
||||
|
||||
+ (BOOL)canProcessRequest:(NSURLRequest *)request {
|
||||
return [[[request URL] pathExtension] isEqualToString:@"xml"] || [super canProcessRequest:request];
|
||||
}
|
||||
|
||||
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
||||
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
self.completionBlock = ^ {
|
||||
dispatch_async(xml_request_operation_processing_queue(), ^(void) {
|
||||
NSXMLParser *XMLParser = self.responseXMLParser;
|
||||
|
||||
if (self.error) {
|
||||
if (failure) {
|
||||
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
failure(self, self.error);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (success) {
|
||||
dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{
|
||||
success(self, XMLParser);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,78 @@
|
||||
// UIImageView+AFNetworking.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>
|
||||
#import "AFImageRequestOperation.h"
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL.
|
||||
*/
|
||||
@interface UIImageView (AFNetworking)
|
||||
|
||||
/**
|
||||
Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL, and sets it the request is finished. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
|
||||
|
||||
@discussion By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
|
||||
|
||||
@param url The URL used for the image request.
|
||||
*/
|
||||
- (void)setImageWithURL:(NSURL *)url;
|
||||
|
||||
/**
|
||||
Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
|
||||
|
||||
@param url The URL used for the image request.
|
||||
@param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
|
||||
|
||||
@discussion By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
|
||||
*/
|
||||
- (void)setImageWithURL:(NSURL *)url
|
||||
placeholderImage:(UIImage *)placeholderImage;
|
||||
|
||||
/**
|
||||
Creates and enqueues an image request operation, which asynchronously downloads the image with the specified URL request object. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
|
||||
|
||||
@param urlRequest The URL request used for the image request.
|
||||
@param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
|
||||
@param success A block to be executed when the image request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the request and response parameters will be `nil`.
|
||||
@param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
|
||||
|
||||
@discussion If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is executed.
|
||||
*/
|
||||
- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
|
||||
placeholderImage:(UIImage *)placeholderImage
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Cancels any executing image request operation for the receiver, if one exists.
|
||||
*/
|
||||
- (void)cancelImageRequestOperation;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,180 @@
|
||||
// UIImageView+AFNetworking.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 <Foundation/Foundation.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
#import "UIImageView+AFNetworking.h"
|
||||
|
||||
@interface AFImageCache : NSCache
|
||||
- (UIImage *)cachedImageForRequest:(NSURLRequest *)request;
|
||||
- (void)cacheImage:(UIImage *)image
|
||||
forRequest:(NSURLRequest *)request;
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
static char kAFImageRequestOperationObjectKey;
|
||||
|
||||
@interface UIImageView (_AFNetworking)
|
||||
@property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFImageRequestOperation *af_imageRequestOperation;
|
||||
@end
|
||||
|
||||
@implementation UIImageView (_AFNetworking)
|
||||
@dynamic af_imageRequestOperation;
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation UIImageView (AFNetworking)
|
||||
|
||||
- (AFHTTPRequestOperation *)af_imageRequestOperation {
|
||||
return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, &kAFImageRequestOperationObjectKey);
|
||||
}
|
||||
|
||||
- (void)af_setImageRequestOperation:(AFImageRequestOperation *)imageRequestOperation {
|
||||
objc_setAssociatedObject(self, &kAFImageRequestOperationObjectKey, imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
+ (NSOperationQueue *)af_sharedImageRequestOperationQueue {
|
||||
static NSOperationQueue *_af_imageRequestOperationQueue = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_af_imageRequestOperationQueue = [[NSOperationQueue alloc] init];
|
||||
[_af_imageRequestOperationQueue setMaxConcurrentOperationCount:NSOperationQueueDefaultMaxConcurrentOperationCount];
|
||||
});
|
||||
|
||||
return _af_imageRequestOperationQueue;
|
||||
}
|
||||
|
||||
+ (AFImageCache *)af_sharedImageCache {
|
||||
static AFImageCache *_af_imageCache = nil;
|
||||
static dispatch_once_t oncePredicate;
|
||||
dispatch_once(&oncePredicate, ^{
|
||||
_af_imageCache = [[AFImageCache alloc] init];
|
||||
});
|
||||
|
||||
return _af_imageCache;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)setImageWithURL:(NSURL *)url {
|
||||
[self setImageWithURL:url placeholderImage:nil];
|
||||
}
|
||||
|
||||
- (void)setImageWithURL:(NSURL *)url
|
||||
placeholderImage:(UIImage *)placeholderImage
|
||||
{
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
|
||||
[request setHTTPShouldHandleCookies:NO];
|
||||
[request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
|
||||
|
||||
[self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
|
||||
}
|
||||
|
||||
- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
|
||||
placeholderImage:(UIImage *)placeholderImage
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
|
||||
{
|
||||
[self cancelImageRequestOperation];
|
||||
|
||||
UIImage *cachedImage = [[[self class] af_sharedImageCache] cachedImageForRequest:urlRequest];
|
||||
if (cachedImage) {
|
||||
self.image = cachedImage;
|
||||
self.af_imageRequestOperation = nil;
|
||||
|
||||
if (success) {
|
||||
success(nil, nil, cachedImage);
|
||||
}
|
||||
} else {
|
||||
self.image = placeholderImage;
|
||||
|
||||
AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
|
||||
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||
if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) {
|
||||
if (success) {
|
||||
success(operation.request, operation.response, responseObject);
|
||||
} else {
|
||||
self.image = responseObject;
|
||||
}
|
||||
|
||||
self.af_imageRequestOperation = nil;
|
||||
}
|
||||
|
||||
[[[self class] af_sharedImageCache] cacheImage:responseObject forRequest:urlRequest];
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) {
|
||||
if (failure) {
|
||||
failure(operation.request, operation.response, error);
|
||||
}
|
||||
|
||||
self.af_imageRequestOperation = nil;
|
||||
}
|
||||
}];
|
||||
|
||||
self.af_imageRequestOperation = requestOperation;
|
||||
|
||||
[[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cancelImageRequestOperation {
|
||||
[self.af_imageRequestOperation cancel];
|
||||
self.af_imageRequestOperation = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
static inline NSString * AFImageCacheKeyFromURLRequest(NSURLRequest *request) {
|
||||
return [[request URL] absoluteString];
|
||||
}
|
||||
|
||||
@implementation AFImageCache
|
||||
|
||||
- (UIImage *)cachedImageForRequest:(NSURLRequest *)request {
|
||||
switch ([request cachePolicy]) {
|
||||
case NSURLRequestReloadIgnoringCacheData:
|
||||
case NSURLRequestReloadIgnoringLocalAndRemoteCacheData:
|
||||
return nil;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return [self objectForKey:AFImageCacheKeyFromURLRequest(request)];
|
||||
}
|
||||
|
||||
- (void)cacheImage:(UIImage *)image
|
||||
forRequest:(NSURLRequest *)request
|
||||
{
|
||||
if (image && request) {
|
||||
[self setObject:image forKey:AFImageCacheKeyFromURLRequest(request)];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,513 @@
|
||||
= 1.1.0 (2012-12-27)
|
||||
|
||||
* Add optional SSL certificate pinning with `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` (Dustin Barker)
|
||||
|
||||
* Add `responseStringEncoding` property to `AFURLConnectionOperation` (Mattt Thompson)
|
||||
|
||||
* Add `userInfo` property to `AFURLConnectionOperation` (Mattt Thompson, Steven Fisher)
|
||||
|
||||
* Change behavior to cause a failure when an operation is cancelled (Daniel Tull)
|
||||
|
||||
* Change return type of class constructors to `instancetype` (@guykogus)
|
||||
|
||||
* Change notifications to always being posted on an asynchronously-dispatched block run on the main queue (Evadne Wu, Mattt Thompson)
|
||||
|
||||
* Change from NSLocalizedString to NSLocalizedStringFromTable with AFNetworking.strings table for localized strings (Cédric Luthi)
|
||||
|
||||
* Change `-appendPartWithHeaders:body:` to add assertion handler for existence of body data parameter (Jonathan Beilin)
|
||||
|
||||
* Change `AFHTTPRequestOperation -responseString` to follow guidelines from RFC 2616 regarding the use of string encoding when none is specified in the response (Jorge Bernal)
|
||||
|
||||
* Change AFHTTPClient parameter serialization dictionary keys with `caseInsensitiveCompare:` to ensure
|
||||
deterministic ordering of query string parameters, which may otherwise
|
||||
cause ambiguous representations of nested parameters (James Coleman,
|
||||
Mattt Thompson)
|
||||
|
||||
* Fix -Wstrict-selector-match warnings raised by Xcode 4.6DP3 (Jesse Collis, Cédric Luthi)
|
||||
|
||||
* Fix NSJSONSerialization crash with Unicode character escapes in JSON response (Mathijs Kadijk)
|
||||
|
||||
* Fix issue with early return in -startMonitoringNetworkReachability if network reachability object could not be created (i.e. invalid hostnames) (Basil Shkara)
|
||||
|
||||
* Fix retain cycles in AFImageRequestOperation.m and AFHTTPClient.m caused by strong references within blocks (Nick Forge)
|
||||
|
||||
* Fix issue caused by Rails behavior of returning a single space in head :ok responses, which is interpreted as invalid (Sebastian Ludwig)
|
||||
|
||||
* Fix issue in streaming multipart upload, where final encapsulation boundary would not be appended if it was larger than the available buffer, causing a potential timeout (Tomohisa Takaoka, David Kasper)
|
||||
|
||||
* Fix memory leak of network reachability callback block (Mattt Thompson)
|
||||
|
||||
* Fix `-initWithCoder:` for `AFURLConnectionOperation` and `AFHTTPClient` to cast scalar types (Mattt Thompson)
|
||||
|
||||
* Fix bug in `-enqueueBatchOfHTTPRequestOperations:...` to by using `addOperations:waitUntilFinished:` instead of adding each operation individually. (Mattt Thompson)
|
||||
|
||||
* Change `#warning` messages of checks for `CoreServices` and `MobileCoreServices` to message according to the build target platform (Mattt Thompson)
|
||||
|
||||
* Change `AFQueryStringFromParametersWithEncoding` to create keys string representations using the description method as specified in documentation (Cédric Luthi)
|
||||
|
||||
* Fix __unused keywords for better Xcode indexing (Christian Rasmussen)
|
||||
|
||||
* Fix warning: unused parameter 'x' [-Werror,-Wunused-parameter] (Oliver Jones)
|
||||
|
||||
* Fix warning: property is assumed atomic by default [-Werror,-Wimplicit-atomic-properties] (Oliver Jones)
|
||||
|
||||
* Fix warning: weak receiver may be unpredictably null in ARC mode [-Werror,-Wreceiver-is-weak] (Oliver Jones)
|
||||
|
||||
* Fix warning: multiple methods named 'selector' found [-Werror,-Wstrict-selector-match] (Oliver Jones)
|
||||
|
||||
* Fix warning: 'macro' is not defined, evaluates to 0 (Oliver Jones)
|
||||
|
||||
* Fix warning: atomic by default property 'X' has a user (Oliver Jones)defined getter (property should be marked 'atomic' if this is intended) [-Werror, -Wcustom-atomic-properties] (Oliver Jones)
|
||||
|
||||
* Fix warning: 'response' was marked unused but was used [-Werror,-Wused-but-marked-unused] (Oliver Jones)
|
||||
|
||||
* Fix warning: enumeration value 'AFFinalBoundaryPhase' not explicitly handled in switch [-Werror,-Wswitch-enum] (Oliver Jones)
|
||||
|
||||
= 1.0.1 / 2012-11-01
|
||||
|
||||
* Fix error in multipart upload streaming, where byte range at boundaries
|
||||
was not correctly calculated (Stan Chang Khin Boon)
|
||||
|
||||
* If a success block is specified to `UIImageView -setImageWithURLRequest:
|
||||
placeholderImage:success:failure`:, it is now the responsibility of the
|
||||
block to set the image of the image view (Mattt Thompson)
|
||||
|
||||
* Add `JSONReadingOptions` property to `AFJSONRequestOperation` (Jeremy
|
||||
Foo, Mattt Thompson)
|
||||
|
||||
* Using __weak self / __strong self pattern to break retain cycles in
|
||||
background task and network reachability blocks (Jerry Beers, Dan Weeks)
|
||||
|
||||
* Fix parameter encoding to leave period (`.`) unescaped (Diego Torres)
|
||||
|
||||
* Fixing last file component in multipart form part creation (Sylver
|
||||
Bruneau)
|
||||
|
||||
* Remove executable permission on AFHTTPClient source files (Andrew
|
||||
Sardone)
|
||||
|
||||
* Fix warning (error with -Werror) on implicit 64 to 32 conversion (Dan
|
||||
Weeks)
|
||||
|
||||
* Add GitHub's .gitignore file (Nate Stedman)
|
||||
|
||||
* Updates to README (@ckmcc)
|
||||
|
||||
= 1.0 / 2012-10-15
|
||||
|
||||
* AFNetworking now requires iOS 5 / Mac OSX 10.7 or higher (Mattt Thompson)
|
||||
|
||||
* AFNetworking now uses Automatic Reference Counting (ARC) (Mattt Thompson)
|
||||
|
||||
* AFNetworking raises compiler warnings for missing features when
|
||||
SystemConfiguration or CoreServices / MobileCoreServices frameworks are not
|
||||
included in the project and imported in the precompiled headers (Mattt
|
||||
Thompson)
|
||||
|
||||
* AFNetworking now raises compiler error when not compiled with ARC (Steven
|
||||
Fisher)
|
||||
|
||||
* Add `NSCoding` and `NSCopying` protocol conformance to
|
||||
`AFURLConnectionOperation` and `AFHTTPClient` (Mattt Thompson)
|
||||
|
||||
* Add substantial improvements HTTP multipart streaming support, having
|
||||
files streamed directly from disk and read sequentially from a custom input
|
||||
stream (Max Lansing, Stan Chang Khin Boon, Mattt Thompson)
|
||||
|
||||
* Add `AFMultipartFormData -throttleBandwidthWithPacketSize:delay:` as
|
||||
workaround to issues when uploading over 3G (Mattt Thompson)
|
||||
|
||||
* Add request and response to `userInfo` of errors returned from failing
|
||||
`AFHTTPRequestOperation` (Mattt Thompson)
|
||||
|
||||
* Add `userInfo` dictionary with current status in reachability changes
|
||||
(Mattt Thompson)
|
||||
|
||||
* Add `Accept` header for image requests in `UIImageView` category (Bratley
|
||||
Lower)
|
||||
|
||||
* Add explicit declaration of `NSURLConnection` delegate methods so that
|
||||
they can be overridden in subclasses (Mattt Thompson, Evan Grim)
|
||||
|
||||
* Add parameter validation to match conditions specified in documentation
|
||||
(Jason Brennan, Mattt Thompson)
|
||||
|
||||
* Add import to `UIKit` to avoid build errors from `UIDevice` references in
|
||||
`User-Agent` default header (Blake Watters)
|
||||
|
||||
* Remove `AFJSONUtilities` in favor of `NSJSONSerialization` (Mattt Thompson)
|
||||
|
||||
* Remove `extern` declaration of `AFURLEncodedStringFromStringWithEncoding`
|
||||
function (`CFURLCreateStringByAddingPercentEscapes` should be used instead)
|
||||
(Mattt Thompson)
|
||||
|
||||
* Remove `setHTTPShouldHandleCookies:NO` from `AFHTTPClient` (@phamsonha,
|
||||
Mattt Thompson)
|
||||
|
||||
* Remove `dispatch_retain` / `dispatch_release` with ARC in iOS 6 (Benoit
|
||||
Bourdon)
|
||||
|
||||
* Fix threading issue with `AFNetworkActivityIndicatorManager` (Eric Patey)
|
||||
|
||||
* Fix issue where `AFNetworkActivityIndicatorManager` count could become
|
||||
negative (@ap4y)
|
||||
|
||||
* Fix properties to explicitly set options to suppress warnings (Wen-Hao
|
||||
Lue, Mattt Thompson)
|
||||
|
||||
* Fix compiler warning caused by mismatched types in upload / download
|
||||
progress blocks (Gareth du Plooy, tomas.a)
|
||||
|
||||
* Fix weak / strong variable relationships in `completionBlock` (Peter
|
||||
Steinberger)
|
||||
|
||||
* Fix string formatting syntax warnings caused by type mismatch (David
|
||||
Keegan, Steven Fisher, George Cox)
|
||||
|
||||
* Fix minor potential security vulnerability by explicitly using string
|
||||
format in NSError localizedDescription value in userInfo (Steven Fisher)
|
||||
|
||||
* Fix `AFURLConnectionOperation -pause` by adding state checks to prevent
|
||||
likely memory issues when resuming (Mattt Thompson)
|
||||
|
||||
* Fix warning caused by miscast of type when
|
||||
`CLANG_WARN_IMPLICIT_SIGN_CONVERSION` is set (Steven Fisher)
|
||||
|
||||
* Fix incomplete implementation warning in example code (Steven Fisher)
|
||||
|
||||
* Fix warning caused by using `==` comparator on floats (Steven Fisher)
|
||||
|
||||
* Fix iOS 4 bug where file URLs return `NSURLResponse` rather than
|
||||
`NSHTTPURLResponse` objects (Leo Lobato)
|
||||
|
||||
* Fix calculation of finished operations in batch operation progress
|
||||
callback (Mattt Thompson)
|
||||
|
||||
* Fix documentation typos (Steven Fisher, Matthias Wessendorf,
|
||||
jorge@miv.uk.com)
|
||||
|
||||
* Fix `hasAcceptableStatusCode` to return true after a network failure (Tony
|
||||
Million)
|
||||
|
||||
* Fix warning about missing prototype for private static method (Stephan
|
||||
Diederich)
|
||||
|
||||
* Fix issue where `nil` content type resulted in unacceptable content type
|
||||
(Mattt Thompson)
|
||||
|
||||
* Fix bug related to setup and scheduling of output stream (Stephen Tramer)
|
||||
|
||||
* Fix AFContentTypesFromHTTPHeader to correctly handle comma-delimited
|
||||
content types (Peyman, Mattt Thompson, @jsm174)
|
||||
|
||||
* Fix crash caused by `_networkReachability` not being set to `NULL` after
|
||||
releasing (Blake Watters)
|
||||
|
||||
* Fix Podspec to correctly import required headers and use ARC (Eloy Durán,
|
||||
Blake Watters)
|
||||
|
||||
* Fix query string parameter escaping to leave square brackets unescaped
|
||||
(Mattt Thompson)
|
||||
|
||||
* Fix query string parameter encoding of `NSNull` values (Daniel Rinser)
|
||||
|
||||
* Fix error caused by referencing `__IPHONE_OS_VERSION_MIN_REQUIRED` without
|
||||
importing `Availability.h` (Blake Watters)
|
||||
|
||||
* Update example to use App.net API, as Twitter shut off its unauthorized
|
||||
access to the public timeline (Mattt Thompson)
|
||||
|
||||
* Update `AFURLConnectionOperation` to replace `NSAutoReleasePool` with
|
||||
`@autoreleasepool` (Mattt Thompson)
|
||||
|
||||
* Update `AFHTTPClient` operation queue to specify
|
||||
`NSOperationQueueDefaultMaxConcurrentOperationCount` rather than
|
||||
previously-defined constant (Mattt Thompson)
|
||||
|
||||
* Update `AFHTTPClient -initWithBaseURL` to automatically append trailing
|
||||
slash, so as to fix common issue where default path is not respected without
|
||||
trailing slash (Steven Fisher)
|
||||
|
||||
* Update default `AFHTTPClient` `User-Agent` header strings (Mattt Thompson,
|
||||
Steven Fisher)
|
||||
|
||||
* Update icons for iOS example application (Mattt Thompson)
|
||||
|
||||
* Update `numberOfCompletedOperations` variable in progress block to be
|
||||
renamed to `numberOfFinishedOperations` (Mattt Thompson)
|
||||
|
||||
|
||||
= 0.10.0 / 2012-06-26
|
||||
|
||||
* Add Twitter Mac Example application (Mattt Thompson)
|
||||
|
||||
* Add note in README about how to set `-fno-objc-arc` flag for multiple files
|
||||
at once (Pål Brattberg)
|
||||
|
||||
* Add note in README about 64-bit architecture requirement (@rmuginov, Mattt
|
||||
Thompson)
|
||||
|
||||
* Add note in `AFNetworkActivityIndicatorManager` about not having to manually
|
||||
manage animation state (Mattt Thompson)
|
||||
|
||||
* Add missing block parameter name for `imageProcessingBlock` (Francois
|
||||
Lambert)
|
||||
|
||||
* Add NextiveJson to list of supported JSON libraries (Mattt Thompson)
|
||||
|
||||
* Restore iOS 4.0 compatibility with `addAcceptableStatusCodes:` and
|
||||
`addAcceptableContentTypes:` (Zachary Waldowski)
|
||||
|
||||
* Update `AFHTTPClient` to use HTTP pipelining for `GET` and `HEAD` requests by
|
||||
default (Mattt Thompson)
|
||||
|
||||
* Remove @private ivar declaration in headers (Peter Steinberger, Mattt
|
||||
Thompson)
|
||||
|
||||
* Fix potential premature deallocation of _skippedCharacterSet (Tom Wanielista,
|
||||
Mattt Thompson)
|
||||
|
||||
* Fix potential issue in `setOutputStream` by closing any existing
|
||||
`outputStream` (Mattt Thompson)
|
||||
|
||||
* Fix filename in AFHTTPClient header (Steven Fisher)
|
||||
|
||||
* Fix documentation for UIImageView+AFNetworking (Mattt Thompson)
|
||||
|
||||
* Fix HTTP multipart form format, which caused issues with Tornado web server
|
||||
(Matt Chen)
|
||||
|
||||
* Fix `AFHTTPClient` to not append empty data into multipart form data (Jon
|
||||
Parise)
|
||||
|
||||
* Fix URL encoding normalization to not conditionally escape percent-encoded
|
||||
strings (João Prado Maia, Kendall Helmstetter Gelner, @cysp, Mattt Thompson)
|
||||
|
||||
* Fix `AFHTTPClient` documentation reference of
|
||||
`HTTPRequestOperationWithRequest:success:failure` (Shane Vitarana)
|
||||
|
||||
* Add `AFURLRequestOperation -setRedirectResponseBlock:` (Kevin Harwood)
|
||||
|
||||
* Fix `AFURLConnectionOperation` compilation error by conditionally importing
|
||||
UIKit framework (Steven Fisher)
|
||||
|
||||
* Fix issue where image processing block is not called correctly with success
|
||||
block in `AFImageRequestOperation` (Sergey Gavrilyuk)
|
||||
|
||||
* Fix leaked dispatch group in batch operations (@andyegorov, Mattt Thompson)
|
||||
|
||||
* Fix support for non-LLVM compilers in `AFNetworkActivityIndicatorManager`
|
||||
(Abraham Vegh, Bill Williams, Mattt Thompson)
|
||||
|
||||
* Fix AFHTTPClient to not add unnecessary data when constructing multipart form
|
||||
request with nil parameters (Taeho Kim)
|
||||
|
||||
= 1.0RC1 / 2012-04-25
|
||||
|
||||
* Add `AFHTTPRequestOperation +addAcceptableStatusCodes /
|
||||
+addAcceptableContentTypes` to dynamically add acceptable status codes and
|
||||
content types on the class level (Mattt Thompson)
|
||||
|
||||
* Add support for compound and complex `Accept` headers that include multiple
|
||||
content types and / or specify a particular character encoding (Mattt Thompson)
|
||||
|
||||
* Add `AFURLConnectionOperation
|
||||
-setShouldExecuteAsBackgroundTaskWithExpirationHandler:` to have operations
|
||||
finish once an app becomes inactive (Mattt Thompson)
|
||||
|
||||
* Add support for pausing / resuming request operations (Peter Steinberger,
|
||||
Mattt Thompson)
|
||||
|
||||
* Improve network reachability functionality in `AFHTTPClient`, including a
|
||||
distinction between WWan and WiFi reachability (Kevin Harwood, Mattt Thompson)
|
||||
|
||||
|
||||
= 0.9.2 / 2012-04-25
|
||||
|
||||
* Add thread safety to `AFNetworkActivityIndicator` (Peter Steinberger, Mattt
|
||||
Thompson)
|
||||
|
||||
* Document requirement of available JSON libraries for decoding responses in
|
||||
`AFJSONRequestOperation` and parameter encoding in `AFHTTPClient` (Mattt
|
||||
Thompson)
|
||||
|
||||
* Fix `AFHTTPClient` parameter encoding (Mattt Thompson)
|
||||
|
||||
* Fix `AFJSONEncode` and `AFJSONDecode` to use `SBJsonWriter` and
|
||||
`SBJsonParser` instead of `NSObject+SBJson` (Oliver Eikemeier)
|
||||
|
||||
* Fix bug where `AFJSONDecode` does not return errors (Alex Michaud)
|
||||
|
||||
* Fix compiler warning for undeclared
|
||||
`AFQueryStringComponentFromKeyAndValueWithEncoding` function (Mattt Thompson)
|
||||
|
||||
* Fix cache policy for URL requests (Peter Steinberger)
|
||||
|
||||
* Fix race condition bug in `UIImageView+AFNetworking` caused by incorrectly
|
||||
nil-ing request operations (John Wu)
|
||||
|
||||
* Fix reload button in Twitter example (Peter Steinberger)
|
||||
|
||||
* Improve batched operation by deferring execution of batch completion block
|
||||
until all component request completion blocks have finished (Patrick Hernandez,
|
||||
Kevin Harwood, Mattt Thompson)
|
||||
|
||||
* Improve performance of image request decoding by dispatching to background
|
||||
queue (Mattt Thompson)
|
||||
|
||||
* Revert `AFImageCache` to cache image objects rather than `NSPurgeableData`
|
||||
(Tony Million, Peter Steinberger, Mattt Thompson)
|
||||
|
||||
* Remove unnecessary KVO `willChangeValueForKey:` / `didChangeValueForKey:`
|
||||
calls (Peter Steinberger)
|
||||
|
||||
* Remove unnecessary @private ivar declarations in headers (Peter Steinberger,
|
||||
Mattt Thompson)
|
||||
|
||||
* Remove @try-@catch block wrapping network thread entry point (Charles T. Ahn)
|
||||
|
||||
|
||||
= 0.9.1 / 2012-03-19
|
||||
|
||||
* Create Twitter example application (Mattt Thompson)
|
||||
|
||||
* Add support for nested array and dictionary parameters for query string and
|
||||
form-encoded requests (Mathieu Hausherr, Josh Chung, Mattt Thompson)
|
||||
|
||||
* Add `AFURLConnectionOperation -setCacheResponseBlock:`, which allows the
|
||||
behavior of the `NSURLConnectionDelegate` method
|
||||
`-connection:willCacheResponse:` to be overridden without subclassing (Mattt
|
||||
Thompson)
|
||||
|
||||
* Add `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` macros for
|
||||
NSURLConnection authentication delegate methods (Mattt Thompson)
|
||||
|
||||
* Add properties for custom success / failure callback queues (Peter
|
||||
Steinberger)
|
||||
|
||||
* Add notifications for network reachability changes to `AFHTTPClient` (Mattt
|
||||
Thompson)
|
||||
|
||||
* Add `AFHTTPClient -patchPath:` convenience method (Mattt Thompson)
|
||||
|
||||
* Add support for NextiveJson (Adrian Kosmaczewski)
|
||||
|
||||
* Improve network reachability checks (C. Bess)
|
||||
|
||||
* Improve NSIndexSet formatting in error strings (Jon Parise)
|
||||
|
||||
* Document crashing behavior in iOS 4 loading a file:// URL (Mattt Thompson)
|
||||
|
||||
* Fix crash caused by `AFHTTPClient -cancelAllHTTPOperationsWithMethod:` not
|
||||
checking operation to be instance of `AFHTTPRequestOperation` (Mattt Thompson)
|
||||
|
||||
* Fix crash caused by passing `nil` URL in requests (Sam Soffes)
|
||||
|
||||
* Fix errors caused by connection property not being nil'd out after an
|
||||
operation finishes (Kevin Harwood, @zdzisiekpu)
|
||||
|
||||
* Fix crash caused by passing `NULL` error pointer when setting `NSInvocation`
|
||||
in `AFJSONEncode` and `AFJSONDecode` (Tyler Stromberg)
|
||||
|
||||
* Fix batch operation completion block returning on background thread (Patrick
|
||||
Hernandez)
|
||||
|
||||
* Fix documentation for UIImageView+AFNetworking (Dominic Dagradi)
|
||||
|
||||
* Fix race condition caused by `AFURLConnectionOperation` being cancelled on
|
||||
main thread, rather than network thread (Erik Olsson)
|
||||
|
||||
* Fix `AFURLEncodedStringFromStringWithEncoding` to correctly handle cases
|
||||
where % is used as a literal rather than as part of a percent escape code
|
||||
(Mattt Thompson)
|
||||
|
||||
* Fix missing comma in `+defaultAcceptableContentTypes` for
|
||||
`AFImageRequestOperation` (Michael Schneider)
|
||||
|
||||
|
||||
= 0.9.0 / 2012-01-23
|
||||
|
||||
* Add thread-safe behavior to `AFURLConnectionOperation` (Mattt Thompson)
|
||||
|
||||
* Add batching of operations for `AFHTTPClient` (Mattt Thompson)
|
||||
|
||||
* Add authentication challenge callback block to override default
|
||||
implementation of `connection:didReceiveAuthenticationChallenge:` in
|
||||
`AFURLConnectionOperation` (Mattt Thompson)
|
||||
|
||||
* Add `_AFNETWORKING_PREFER_NSJSONSERIALIZATION_`, which, when defined,
|
||||
short-circuits the standard preference ordering used in `AFJSONEncode` and
|
||||
`AFJSONDecode` to use `NSJSONSerialization` when available, falling back on
|
||||
third-party-libraries. (Mattt Thompson, Shane Vitarana)
|
||||
|
||||
* Add custom `description` for `AFURLConnectionOperation` and `AFHTTPClient`
|
||||
(Mattt Thompson)
|
||||
|
||||
* Add `text/javascript` to default acceptable content types for
|
||||
`AFJSONRequestOperation` (Jake Boxer)
|
||||
|
||||
* Add `imageScale` property to change resolution of images constructed from
|
||||
cached data (Štěpán Petrů)
|
||||
|
||||
* Add note about third party JSON libraries in README (David Keegan)
|
||||
|
||||
* `AFQueryStringFromParametersWithEncoding` formats `NSArray` values in the
|
||||
form `key[]=value1&key[]=value2` instead of `key=(value1,value2)` (Dan Thorpe)
|
||||
|
||||
* `AFImageRequestOperation -responseImage` on OS X uses `NSBitmapImageRep` to
|
||||
determine the correct pixel dimensions of the image (David Keegan)
|
||||
|
||||
* `AFURLConnectionOperation` `connection` has memory management policy `assign`
|
||||
to avoid retain cycles caused by `NSURLConnection` retaining its delegate
|
||||
(Mattt Thompson)
|
||||
|
||||
* `AFURLConnectionOperation` calls super implementation for `-isReady`,
|
||||
following the guidelines for `NSOperation` subclasses (Mattt Thompson)
|
||||
|
||||
* `UIImageView -setImageWithURL:` and related methods call success callback
|
||||
after setting image (Cameron Boehmer)
|
||||
|
||||
* Cancel request if an authentication challenge has no suitable credentials in
|
||||
`AFURLConnectionOperation -connection:didReceiveAuthenticationChallenge:`
|
||||
(Jorge Bernal)
|
||||
|
||||
* Remove exception from
|
||||
`multipartFormRequestWithMethod:path:parameters:constructing BodyWithBlock:`
|
||||
raised when certain HTTP methods are used. (Mattt Thompson)
|
||||
|
||||
* Remove `AFImageCache` from public API, moving it into private implementation
|
||||
of `UIImageView+AFNetworking` (Mattt Thompson)
|
||||
|
||||
* Mac example application makes better use of AppKit technologies and
|
||||
conventions (Mattt Thompson)
|
||||
|
||||
* Fix issue with multipart form boundaries in `AFHTTPClient
|
||||
-multipartFormRequestWithMethod:path:parameters:constructing BodyWithBlock:`
|
||||
(Ray Morgan, Mattt Thompson, Sam Soffes)
|
||||
|
||||
* Fix "File Upload with Progress Callback" code snippet in README (Larry Legend)
|
||||
|
||||
* Fix to SBJSON invocations in `AFJSONEncode` and `AFJSONDecode` (Matthias
|
||||
Tretter, James Frye)
|
||||
|
||||
* Fix documentation for `AFHTTPClient requestWithMethod:path:parameters:`
|
||||
(Michael Parker)
|
||||
|
||||
* Fix `Content-Disposition` headers used for multipart form construction
|
||||
(Michael Parker)
|
||||
|
||||
* Add network reachability status change callback property to `AFHTTPClient`.
|
||||
(Mattt Thompson, Kevin Harwood)
|
||||
|
||||
* Fix exception handling in `AFJSONEncode` and `AFJSONDecode` (David Keegan)
|
||||
|
||||
* Fix `NSData` initialization with string in `AFBase64EncodedStringFromString`
|
||||
(Adam Ernst, Mattt Thompson)
|
||||
|
||||
* Fix error check in `appendPartWithFileURL:name:error:` (Warren Moore,
|
||||
Baldoph, Mattt Thompson)
|
||||
|
||||
* Fix compiler warnings for certain configurations (Charlie Williams)
|
||||
|
||||
* Fix bug caused by passing zero-length `responseData` to response object
|
||||
initializers (Mattt Thompson, Serge Paquet)
|
||||
@@ -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>
|
||||
@@ -0,0 +1,361 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
F8129C001591061B009BFE23 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8129BFF1591061B009BFE23 /* Cocoa.framework */; };
|
||||
F8129C321591073C009BFE23 /* AFAppDotNetAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C251591073C009BFE23 /* AFAppDotNetAPIClient.m */; };
|
||||
F8129C341591073C009BFE23 /* Post.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C2B1591073C009BFE23 /* Post.m */; };
|
||||
F8129C351591073C009BFE23 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C2D1591073C009BFE23 /* User.m */; };
|
||||
F8129C6F15910B15009BFE23 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C6E15910B15009BFE23 /* main.m */; };
|
||||
F8129C7115910B3E009BFE23 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F8129C7015910B3E009BFE23 /* MainMenu.xib */; };
|
||||
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 */; };
|
||||
F8A847CF161F55A500940F39 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8A847CE161F55A500940F39 /* CoreServices.framework */; };
|
||||
F8A847D2161F55AC00940F39 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8A847D1161F55AC00940F39 /* SystemConfiguration.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
F8129BFB1591061B009BFE23 /* AFNetworking Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AFNetworking Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F8129BFF1591061B009BFE23 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
||||
F8129C021591061B009BFE23 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
||||
F8129C031591061B009BFE23 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
|
||||
F8129C041591061B009BFE23 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
F8129C251591073C009BFE23 /* AFAppDotNetAPIClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFAppDotNetAPIClient.m; path = Classes/AFAppDotNetAPIClient.m; sourceTree = SOURCE_ROOT; };
|
||||
F8129C2A1591073C009BFE23 /* Post.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Post.h; sourceTree = "<group>"; };
|
||||
F8129C2B1591073C009BFE23 /* Post.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Post.m; 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>"; };
|
||||
F8129C311591073C009BFE23 /* AFAppDotNetAPIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFAppDotNetAPIClient.h; path = Classes/AFAppDotNetAPIClient.h; 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; };
|
||||
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; };
|
||||
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>"; };
|
||||
F8A847CE161F55A500940F39 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
|
||||
F8A847D1161F55AC00940F39 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
F8129BF81591061B009BFE23 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8A847D2161F55AC00940F39 /* SystemConfiguration.framework in Frameworks */,
|
||||
F8A847CF161F55A500940F39 /* CoreServices.framework in Frameworks */,
|
||||
F8129C001591061B009BFE23 /* Cocoa.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
F8129BF01591061B009BFE23 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8A847D1161F55AC00940F39 /* SystemConfiguration.framework */,
|
||||
F8A847CE161F55A500940F39 /* CoreServices.framework */,
|
||||
F877018B159A1CE700B45C0D /* AFNetworking Example.entitlements */,
|
||||
F8129C051591061B009BFE23 /* Classes */,
|
||||
F8129C4C15910901009BFE23 /* Vendor */,
|
||||
F8129BFE1591061B009BFE23 /* Frameworks */,
|
||||
F8129BFC1591061B009BFE23 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8129BFC1591061B009BFE23 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8129BFB1591061B009BFE23 /* AFNetworking Example.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8129BFE1591061B009BFE23 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8129BFF1591061B009BFE23 /* Cocoa.framework */,
|
||||
F8129C011591061B009BFE23 /* Other Frameworks */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8129C011591061B009BFE23 /* Other Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8129C021591061B009BFE23 /* AppKit.framework */,
|
||||
F8129C031591061B009BFE23 /* CoreData.framework */,
|
||||
F8129C041591061B009BFE23 /* Foundation.framework */,
|
||||
);
|
||||
name = "Other Frameworks";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8129C051591061B009BFE23 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8129C311591073C009BFE23 /* AFAppDotNetAPIClient.h */,
|
||||
F8129C251591073C009BFE23 /* AFAppDotNetAPIClient.m */,
|
||||
F8129C7615910C40009BFE23 /* AppDelegate.h */,
|
||||
F8129C7515910C40009BFE23 /* AppDelegate.m */,
|
||||
F8129C291591073C009BFE23 /* Models */,
|
||||
F8129C061591061B009BFE23 /* Supporting Files */,
|
||||
);
|
||||
name = Classes;
|
||||
path = "AFNetworking-Mac-Example";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8129C061591061B009BFE23 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8129C6E15910B15009BFE23 /* main.m */,
|
||||
F8129C7015910B3E009BFE23 /* MainMenu.xib */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8129C291591073C009BFE23 /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8129C2A1591073C009BFE23 /* Post.h */,
|
||||
F8129C2B1591073C009BFE23 /* Post.m */,
|
||||
F8129C2C1591073C009BFE23 /* User.h */,
|
||||
F8129C2D1591073C009BFE23 /* User.m */,
|
||||
);
|
||||
name = Models;
|
||||
path = Classes/Models;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
F8129C4C15910901009BFE23 /* Vendor */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F82EB083159A172500B10B56 /* AFNetworking */,
|
||||
);
|
||||
name = Vendor;
|
||||
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 */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
F8129BFA1591061B009BFE23 /* AFNetworking Example */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = F8129C191591061B009BFE23 /* Build configuration list for PBXNativeTarget "AFNetworking Example" */;
|
||||
buildPhases = (
|
||||
F8129BF71591061B009BFE23 /* Sources */,
|
||||
F8129BF81591061B009BFE23 /* Frameworks */,
|
||||
F8129BF91591061B009BFE23 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "AFNetworking Example";
|
||||
productName = "AFNetworking-Mac-Example";
|
||||
productReference = F8129BFB1591061B009BFE23 /* AFNetworking Example.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
F8129BF21591061B009BFE23 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0450;
|
||||
};
|
||||
buildConfigurationList = F8129BF51591061B009BFE23 /* Build configuration list for PBXProject "AFNetworking Mac Example" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = F8129BF01591061B009BFE23;
|
||||
productRefGroup = F8129BFC1591061B009BFE23 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
F8129BFA1591061B009BFE23 /* AFNetworking Example */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
F8129BF91591061B009BFE23 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8129C7115910B3E009BFE23 /* MainMenu.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
F8129BF71591061B009BFE23 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8129C341591073C009BFE23 /* Post.m in Sources */,
|
||||
F8129C351591073C009BFE23 /* User.m in Sources */,
|
||||
F8129C321591073C009BFE23 /* AFAppDotNetAPIClient.m in Sources */,
|
||||
F8129C6F15910B15009BFE23 /* main.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;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
F8129C171591061B009BFE23 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F8129C181591061B009BFE23 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
F8129C1A1591061B009BFE23 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_ENTITLEMENTS = "AFNetworking Example.entitlements";
|
||||
CODE_SIGN_IDENTITY = "Mac Developer";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = Prefix.pch;
|
||||
INFOPLIST_FILE = "Mac-Info.plist";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F8129C1B1591061B009BFE23 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_ENTITLEMENTS = "AFNetworking Example.entitlements";
|
||||
CODE_SIGN_IDENTITY = "Mac Developer";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = Prefix.pch;
|
||||
INFOPLIST_FILE = "Mac-Info.plist";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
F8129BF51591061B009BFE23 /* Build configuration list for PBXProject "AFNetworking Mac Example" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F8129C171591061B009BFE23 /* Debug */,
|
||||
F8129C181591061B009BFE23 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
F8129C191591061B009BFE23 /* Build configuration list for PBXNativeTarget "AFNetworking Example" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F8129C1A1591061B009BFE23 /* Debug */,
|
||||
F8129C1B1591061B009BFE23 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = F8129BF21591061B009BFE23 /* Project object */;
|
||||
}
|
||||
@@ -0,0 +1,447 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
F8129C7415910C37009BFE23 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C7215910C37009BFE23 /* AppDelegate.m */; };
|
||||
F818101615E6A0C600EF93C2 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */; };
|
||||
F8A847C1161F51A300940F39 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8A847C0161F51A300940F39 /* Default-568h@2x.png */; };
|
||||
F8A847C3161F523E00940F39 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = F8A847C2161F523E00940F39 /* Default.png */; };
|
||||
F8A847C5161F524200940F39 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8A847C4161F524200940F39 /* Default@2x.png */; };
|
||||
F8D0701B14310F4A00653FD3 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469E213957DF700DB05C8 /* SystemConfiguration.framework */; };
|
||||
F8DA09E41396AC040057D0CC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F8DA09E31396AC040057D0CC /* main.m */; };
|
||||
F8E469651395739D00DB05C8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469641395739D00DB05C8 /* UIKit.framework */; };
|
||||
F8E469671395739D00DB05C8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469661395739D00DB05C8 /* Foundation.framework */; };
|
||||
F8E469691395739D00DB05C8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469681395739D00DB05C8 /* CoreGraphics.framework */; };
|
||||
F8E469DF13957DD500DB05C8 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469DE13957DD500DB05C8 /* CoreLocation.framework */; };
|
||||
F8F6E8DC1463424800AD016F /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = F8F6E8D81463424800AD016F /* Icon.png */; };
|
||||
F8F6E8DD1463424800AD016F /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8F6E8D91463424800AD016F /* Icon@2x.png */; };
|
||||
F8FA9491150EF8C100ED4EAD /* AFAppDotNetAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9490150EF8C100ED4EAD /* AFAppDotNetAPIClient.m */; };
|
||||
F8FA9494150EF97E00ED4EAD /* Post.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9493150EF97E00ED4EAD /* Post.m */; };
|
||||
F8FA9497150EF98800ED4EAD /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9496150EF98800ED4EAD /* User.m */; };
|
||||
F8FA949A150EF9DA00ED4EAD /* GlobalTimelineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9499150EF9DA00ED4EAD /* GlobalTimelineViewController.m */; };
|
||||
F8FA94B1150EFEC100ED4EAD /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA949D150EFEC100ED4EAD /* AFHTTPClient.m */; };
|
||||
F8FA94B2150EFEC100ED4EAD /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */; };
|
||||
F8FA94B3150EFEC100ED4EAD /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A1150EFEC100ED4EAD /* AFImageRequestOperation.m */; };
|
||||
F8FA94B4150EFEC100ED4EAD /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A3150EFEC100ED4EAD /* AFJSONRequestOperation.m */; };
|
||||
F8FA94B6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */; };
|
||||
F8FA94B7150EFEC100ED4EAD /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AA150EFEC100ED4EAD /* AFPropertyListRequestOperation.m */; };
|
||||
F8FA94B8150EFEC100ED4EAD /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */; };
|
||||
F8FA94B9150EFEC100ED4EAD /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AE150EFEC100ED4EAD /* AFXMLRequestOperation.m */; };
|
||||
F8FA94BA150EFEC100ED4EAD /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94B0150EFEC100ED4EAD /* UIImageView+AFNetworking.m */; };
|
||||
F8FA94C1150F019100ED4EAD /* PostTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94C0150F019100ED4EAD /* PostTableViewCell.m */; };
|
||||
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 */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
|
||||
F8129C3815910830009BFE23 /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = SOURCE_ROOT; };
|
||||
F8129C7215910C37009BFE23 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; };
|
||||
F8129C7315910C37009BFE23 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; };
|
||||
F8A847C0161F51A300940F39 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
|
||||
F8A847C2161F523E00940F39 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
|
||||
F8A847C4161F524200940F39 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = "<group>"; };
|
||||
F8DA09E31396AC040057D0CC /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; };
|
||||
F8E469601395739C00DB05C8 /* AFNetworking iOS Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AFNetworking iOS Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F8E469641395739D00DB05C8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
F8E469661395739D00DB05C8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
F8E469681395739D00DB05C8 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
F8E4696C1395739D00DB05C8 /* iOS-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "iOS-Info.plist"; sourceTree = "<group>"; };
|
||||
F8E469DE13957DD500DB05C8 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
|
||||
F8E469E013957DF100DB05C8 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
|
||||
F8E469E213957DF700DB05C8 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
|
||||
F8F6E8D81463424800AD016F /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = SOURCE_ROOT; };
|
||||
F8F6E8D91463424800AD016F /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = SOURCE_ROOT; };
|
||||
F8FA948F150EF8C100ED4EAD /* AFAppDotNetAPIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFAppDotNetAPIClient.h; path = Classes/AFAppDotNetAPIClient.h; sourceTree = "<group>"; };
|
||||
F8FA9490150EF8C100ED4EAD /* AFAppDotNetAPIClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFAppDotNetAPIClient.m; path = Classes/AFAppDotNetAPIClient.m; sourceTree = "<group>"; };
|
||||
F8FA9492150EF97E00ED4EAD /* Post.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Post.h; sourceTree = "<group>"; };
|
||||
F8FA9493150EF97E00ED4EAD /* Post.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Post.m; sourceTree = "<group>"; };
|
||||
F8FA9495150EF98800ED4EAD /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = "<group>"; };
|
||||
F8FA9496150EF98800ED4EAD /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = User.m; sourceTree = "<group>"; };
|
||||
F8FA9498150EF9DA00ED4EAD /* GlobalTimelineViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalTimelineViewController.h; sourceTree = "<group>"; };
|
||||
F8FA9499150EF9DA00ED4EAD /* GlobalTimelineViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GlobalTimelineViewController.m; sourceTree = "<group>"; };
|
||||
F8FA949C150EFEC100ED4EAD /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPClient.h; sourceTree = "<group>"; };
|
||||
F8FA949D150EFEC100ED4EAD /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClient.m; sourceTree = "<group>"; };
|
||||
F8FA949E150EFEC100ED4EAD /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = "<group>"; };
|
||||
F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = "<group>"; };
|
||||
F8FA94A0150EFEC100ED4EAD /* AFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFImageRequestOperation.h; 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>"; };
|
||||
F8FA94A3150EFEC100ED4EAD /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONRequestOperation.m; 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>"; };
|
||||
F8FA94A8150EFEC100ED4EAD /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = "<group>"; };
|
||||
F8FA94A9150EFEC100ED4EAD /* AFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFPropertyListRequestOperation.h; sourceTree = "<group>"; };
|
||||
F8FA94AA150EFEC100ED4EAD /* AFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFPropertyListRequestOperation.m; sourceTree = "<group>"; };
|
||||
F8FA94AB150EFEC100ED4EAD /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLConnectionOperation.h; sourceTree = "<group>"; };
|
||||
F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLConnectionOperation.m; sourceTree = "<group>"; };
|
||||
F8FA94AD150EFEC100ED4EAD /* AFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFXMLRequestOperation.h; sourceTree = "<group>"; };
|
||||
F8FA94AE150EFEC100ED4EAD /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFXMLRequestOperation.m; sourceTree = "<group>"; };
|
||||
F8FA94AF150EFEC100ED4EAD /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFNetworking.h"; sourceTree = "<group>"; };
|
||||
F8FA94B0150EFEC100ED4EAD /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFNetworking.m"; sourceTree = "<group>"; };
|
||||
F8FA94BF150F019100ED4EAD /* PostTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PostTableViewCell.h; sourceTree = "<group>"; };
|
||||
F8FA94C0150F019100ED4EAD /* PostTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PostTableViewCell.m; sourceTree = "<group>"; };
|
||||
F8FA94CC150F094D00ED4EAD /* profile-image-placeholder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "profile-image-placeholder.png"; path = "Images/profile-image-placeholder.png"; sourceTree = SOURCE_ROOT; };
|
||||
F8FA94CD150F094D00ED4EAD /* profile-image-placeholder@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "profile-image-placeholder@2x.png"; path = "Images/profile-image-placeholder@2x.png"; sourceTree = SOURCE_ROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
F8E4695D1395739C00DB05C8 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8E469651395739D00DB05C8 /* UIKit.framework in Frameworks */,
|
||||
F8E469671395739D00DB05C8 /* Foundation.framework in Frameworks */,
|
||||
F8E469691395739D00DB05C8 /* CoreGraphics.framework in Frameworks */,
|
||||
F8E469DF13957DD500DB05C8 /* CoreLocation.framework in Frameworks */,
|
||||
F8D0701B14310F4A00653FD3 /* SystemConfiguration.framework in Frameworks */,
|
||||
F818101615E6A0C600EF93C2 /* MobileCoreServices.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
F8DA09C61396AB690057D0CC /* Controllers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8FA9498150EF9DA00ED4EAD /* GlobalTimelineViewController.h */,
|
||||
F8FA9499150EF9DA00ED4EAD /* GlobalTimelineViewController.m */,
|
||||
);
|
||||
name = Controllers;
|
||||
path = Classes/Controllers;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
F8DA09C91396AB690057D0CC /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8FA9492150EF97E00ED4EAD /* Post.h */,
|
||||
F8FA9493150EF97E00ED4EAD /* Post.m */,
|
||||
F8FA9495150EF98800ED4EAD /* User.h */,
|
||||
F8FA9496150EF98800ED4EAD /* User.m */,
|
||||
);
|
||||
name = Models;
|
||||
path = Classes/Models;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
F8DA09CC1396AB690057D0CC /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8FA94BF150F019100ED4EAD /* PostTableViewCell.h */,
|
||||
F8FA94C0150F019100ED4EAD /* PostTableViewCell.m */,
|
||||
);
|
||||
name = Views;
|
||||
path = Classes/Views;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
F8E469551395739C00DB05C8 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8A847C2161F523E00940F39 /* Default.png */,
|
||||
F8A847C4161F524200940F39 /* Default@2x.png */,
|
||||
F8A847C0161F51A300940F39 /* Default-568h@2x.png */,
|
||||
F8E469B71395759C00DB05C8 /* Networking Extensions */,
|
||||
F8E4696A1395739D00DB05C8 /* Classes */,
|
||||
F8E469ED1395812A00DB05C8 /* Images */,
|
||||
F8E469931395743A00DB05C8 /* Vendor */,
|
||||
F8E469631395739D00DB05C8 /* Frameworks */,
|
||||
F8E469611395739C00DB05C8 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8E469611395739C00DB05C8 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8E469601395739C00DB05C8 /* AFNetworking iOS Example.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8E469631395739D00DB05C8 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */,
|
||||
F8E469E213957DF700DB05C8 /* SystemConfiguration.framework */,
|
||||
F8E469E013957DF100DB05C8 /* Security.framework */,
|
||||
F8E469DE13957DD500DB05C8 /* CoreLocation.framework */,
|
||||
F8E469641395739D00DB05C8 /* UIKit.framework */,
|
||||
F8E469661395739D00DB05C8 /* Foundation.framework */,
|
||||
F8E469681395739D00DB05C8 /* CoreGraphics.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8E4696A1395739D00DB05C8 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8129C7315910C37009BFE23 /* AppDelegate.h */,
|
||||
F8129C7215910C37009BFE23 /* AppDelegate.m */,
|
||||
F8DA09C91396AB690057D0CC /* Models */,
|
||||
F8DA09CC1396AB690057D0CC /* Views */,
|
||||
F8DA09C61396AB690057D0CC /* Controllers */,
|
||||
F8E4696B1395739D00DB05C8 /* Supporting Files */,
|
||||
);
|
||||
name = Classes;
|
||||
path = AFNetworkingExample;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8E4696B1395739D00DB05C8 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8DA09E31396AC040057D0CC /* main.m */,
|
||||
F8129C3815910830009BFE23 /* Prefix.pch */,
|
||||
F8E4696C1395739D00DB05C8 /* iOS-Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8E469931395743A00DB05C8 /* Vendor */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8FA949B150EFEC100ED4EAD /* AFNetworking */,
|
||||
);
|
||||
name = Vendor;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8E469B71395759C00DB05C8 /* Networking Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8FA948F150EF8C100ED4EAD /* AFAppDotNetAPIClient.h */,
|
||||
F8FA9490150EF8C100ED4EAD /* AFAppDotNetAPIClient.m */,
|
||||
);
|
||||
name = "Networking Extensions";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8E469ED1395812A00DB05C8 /* Images */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8F6E8D81463424800AD016F /* Icon.png */,
|
||||
F8F6E8D91463424800AD016F /* Icon@2x.png */,
|
||||
F8FA94CC150F094D00ED4EAD /* profile-image-placeholder.png */,
|
||||
F8FA94CD150F094D00ED4EAD /* profile-image-placeholder@2x.png */,
|
||||
);
|
||||
name = Images;
|
||||
path = AFNetworkingExample/Images;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8FA949B150EFEC100ED4EAD /* AFNetworking */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8FA94A8150EFEC100ED4EAD /* AFNetworking.h */,
|
||||
F8FA94AB150EFEC100ED4EAD /* AFURLConnectionOperation.h */,
|
||||
F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */,
|
||||
F8FA949E150EFEC100ED4EAD /* AFHTTPRequestOperation.h */,
|
||||
F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */,
|
||||
F8FA94A2150EFEC100ED4EAD /* AFJSONRequestOperation.h */,
|
||||
F8FA94A3150EFEC100ED4EAD /* AFJSONRequestOperation.m */,
|
||||
F8FA94AD150EFEC100ED4EAD /* AFXMLRequestOperation.h */,
|
||||
F8FA94AE150EFEC100ED4EAD /* AFXMLRequestOperation.m */,
|
||||
F8FA94A9150EFEC100ED4EAD /* AFPropertyListRequestOperation.h */,
|
||||
F8FA94AA150EFEC100ED4EAD /* AFPropertyListRequestOperation.m */,
|
||||
F8FA949C150EFEC100ED4EAD /* AFHTTPClient.h */,
|
||||
F8FA949D150EFEC100ED4EAD /* AFHTTPClient.m */,
|
||||
F8FA94A0150EFEC100ED4EAD /* AFImageRequestOperation.h */,
|
||||
F8FA94A1150EFEC100ED4EAD /* AFImageRequestOperation.m */,
|
||||
F8FA94AF150EFEC100ED4EAD /* UIImageView+AFNetworking.h */,
|
||||
F8FA94B0150EFEC100ED4EAD /* UIImageView+AFNetworking.m */,
|
||||
F8FA94A6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.h */,
|
||||
F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */,
|
||||
);
|
||||
name = AFNetworking;
|
||||
path = ../AFNetworking;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
F8E4695F1395739C00DB05C8 /* AFNetworking iOS Example */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = F8E469811395739D00DB05C8 /* Build configuration list for PBXNativeTarget "AFNetworking iOS Example" */;
|
||||
buildPhases = (
|
||||
F8E4695C1395739C00DB05C8 /* Sources */,
|
||||
F8E4695D1395739C00DB05C8 /* Frameworks */,
|
||||
F8E4695E1395739C00DB05C8 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "AFNetworking iOS Example";
|
||||
productName = AFNetworkingExample;
|
||||
productReference = F8E469601395739C00DB05C8 /* AFNetworking iOS Example.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
F8E469571395739C00DB05C8 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0450;
|
||||
ORGANIZATIONNAME = Gowalla;
|
||||
};
|
||||
buildConfigurationList = F8E4695A1395739C00DB05C8 /* Build configuration list for PBXProject "AFNetworking iOS Example" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = F8E469551395739C00DB05C8;
|
||||
productRefGroup = F8E469611395739C00DB05C8 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
F8E4695F1395739C00DB05C8 /* AFNetworking iOS Example */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
F8E4695E1395739C00DB05C8 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8F6E8DC1463424800AD016F /* Icon.png in Resources */,
|
||||
F8F6E8DD1463424800AD016F /* Icon@2x.png in Resources */,
|
||||
F8FA94D0150F094D00ED4EAD /* profile-image-placeholder.png in Resources */,
|
||||
F8FA94D1150F094D00ED4EAD /* profile-image-placeholder@2x.png in Resources */,
|
||||
F8A847C1161F51A300940F39 /* Default-568h@2x.png in Resources */,
|
||||
F8A847C3161F523E00940F39 /* Default.png in Resources */,
|
||||
F8A847C5161F524200940F39 /* Default@2x.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
F8E4695C1395739C00DB05C8 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8DA09E41396AC040057D0CC /* main.m in Sources */,
|
||||
F8FA9491150EF8C100ED4EAD /* AFAppDotNetAPIClient.m in Sources */,
|
||||
F8FA9494150EF97E00ED4EAD /* Post.m in Sources */,
|
||||
F8FA9497150EF98800ED4EAD /* User.m in Sources */,
|
||||
F8FA949A150EF9DA00ED4EAD /* GlobalTimelineViewController.m in Sources */,
|
||||
F8FA94B1150EFEC100ED4EAD /* AFHTTPClient.m in Sources */,
|
||||
F8FA94B2150EFEC100ED4EAD /* AFHTTPRequestOperation.m in Sources */,
|
||||
F8FA94B3150EFEC100ED4EAD /* AFImageRequestOperation.m in Sources */,
|
||||
F8FA94B4150EFEC100ED4EAD /* AFJSONRequestOperation.m in Sources */,
|
||||
F8FA94B6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m in Sources */,
|
||||
F8FA94B7150EFEC100ED4EAD /* AFPropertyListRequestOperation.m in Sources */,
|
||||
F8FA94B8150EFEC100ED4EAD /* AFURLConnectionOperation.m in Sources */,
|
||||
F8FA94B9150EFEC100ED4EAD /* AFXMLRequestOperation.m in Sources */,
|
||||
F8FA94BA150EFEC100ED4EAD /* UIImageView+AFNetworking.m in Sources */,
|
||||
F8FA94C1150F019100ED4EAD /* PostTableViewCell.m in Sources */,
|
||||
F8129C7415910C37009BFE23 /* AppDelegate.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
F8E4697F1395739D00DB05C8 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F8E469801395739D00DB05C8 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
F8E469821395739D00DB05C8 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = Prefix.pch;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_SHADOW = YES;
|
||||
GCC_WARN_SIGN_COMPARE = YES;
|
||||
GCC_WARN_UNUSED_PARAMETER = NO;
|
||||
INFOPLIST_FILE = "iOS-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WARNING_CFLAGS = "";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F8E469831395739D00DB05C8 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = Prefix.pch;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_SHADOW = YES;
|
||||
GCC_WARN_SIGN_COMPARE = YES;
|
||||
GCC_WARN_UNUSED_PARAMETER = NO;
|
||||
INFOPLIST_FILE = "iOS-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
WARNING_CFLAGS = "";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
F8E4695A1395739C00DB05C8 /* Build configuration list for PBXProject "AFNetworking iOS Example" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F8E4697F1395739D00DB05C8 /* Debug */,
|
||||
F8E469801395739D00DB05C8 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
F8E469811395739D00DB05C8 /* Build configuration list for PBXNativeTarget "AFNetworking iOS Example" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F8E469821395739D00DB05C8 /* Debug */,
|
||||
F8E469831395739D00DB05C8 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = F8E469571395739C00DB05C8 /* Project object */;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// AppDelegate.h
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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 <Availability.h>
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AppDelegate : NSObject <UIApplicationDelegate>
|
||||
|
||||
@property (nonatomic, strong) UIWindow *window;
|
||||
@property (nonatomic, strong) UINavigationController *navigationController;
|
||||
|
||||
@end
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
|
||||
@property (strong) IBOutlet NSWindow *window;
|
||||
@property (strong) IBOutlet NSTableView *tableView;
|
||||
@property (strong) IBOutlet NSArrayController *postsArrayController;
|
||||
|
||||
@end
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
// AppDelegate.m
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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 "AppDelegate.h"
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
#import "GlobalTimelineViewController.h"
|
||||
|
||||
#import "AFNetworkActivityIndicatorManager.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
@synthesize window = _window;
|
||||
@synthesize navigationController = _navigationController;
|
||||
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
|
||||
[NSURLCache setSharedURLCache:URLCache];
|
||||
|
||||
[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
|
||||
|
||||
UITableViewController *viewController = [[GlobalTimelineViewController alloc] initWithStyle:UITableViewStylePlain];
|
||||
self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
|
||||
self.navigationController.navigationBar.tintColor = [UIColor darkGrayColor];
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.window.backgroundColor = [UIColor whiteColor];
|
||||
self.window.rootViewController = self.navigationController;
|
||||
[self.window makeKeyAndVisible];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
#else
|
||||
#import "Post.h"
|
||||
#import "User.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
@synthesize window = _window;
|
||||
@synthesize tableView = _tableView;
|
||||
@synthesize postsArrayController = _postsArrayController;
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
|
||||
NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
|
||||
[NSURLCache setSharedURLCache:URLCache];
|
||||
|
||||
[self.window makeKeyAndOrderFront:self];
|
||||
|
||||
[Post globalTimelinePostsWithBlock:^(NSArray *posts, NSError *error) {
|
||||
if (error) {
|
||||
[[NSAlert alertWithMessageText:NSLocalizedString(@"Error", nil) defaultButton:NSLocalizedString(@"OK", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@",[error localizedDescription]] runModal];
|
||||
}
|
||||
|
||||
self.postsArrayController.content = posts;
|
||||
}];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:kUserProfileImageDidLoadNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
|
||||
[self.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)applicationShouldHandleReopen:(NSApplication *)application
|
||||
hasVisibleWindows:(BOOL)flag
|
||||
{
|
||||
[self.window makeKeyAndOrderFront:self];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
// AFAppDotNetAPIClient.h
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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>
|
||||
#import "AFHTTPClient.h"
|
||||
|
||||
@interface AFAppDotNetAPIClient : AFHTTPClient
|
||||
|
||||
+ (AFAppDotNetAPIClient *)sharedClient;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,55 @@
|
||||
// AFAppDotNetAPIClient.h
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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 "AFAppDotNetAPIClient.h"
|
||||
|
||||
#import "AFJSONRequestOperation.h"
|
||||
|
||||
static NSString * const kAFAppDotNetAPIBaseURLString = @"https://alpha-api.app.net/";
|
||||
|
||||
@implementation AFAppDotNetAPIClient
|
||||
|
||||
+ (AFAppDotNetAPIClient *)sharedClient {
|
||||
static AFAppDotNetAPIClient *_sharedClient = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_sharedClient = [[AFAppDotNetAPIClient alloc] initWithBaseURL:[NSURL URLWithString:kAFAppDotNetAPIBaseURLString]];
|
||||
});
|
||||
|
||||
return _sharedClient;
|
||||
}
|
||||
|
||||
- (id)initWithBaseURL:(NSURL *)url {
|
||||
self = [super initWithBaseURL:url];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
|
||||
|
||||
// Accept HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
|
||||
[self setDefaultHeader:@"Accept" value:@"application/json"];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
// GlobalTimelineViewController.h
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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 <UIKit/UIKit.h>
|
||||
|
||||
@interface GlobalTimelineViewController : UITableViewController
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,114 @@
|
||||
// GlobalTimelineViewController.m
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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 "GlobalTimelineViewController.h"
|
||||
|
||||
#import "Post.h"
|
||||
|
||||
#import "PostTableViewCell.h"
|
||||
|
||||
@interface GlobalTimelineViewController ()
|
||||
- (void)reload:(id)sender;
|
||||
@end
|
||||
|
||||
@implementation GlobalTimelineViewController {
|
||||
@private
|
||||
NSArray *_posts;
|
||||
|
||||
__strong UIActivityIndicatorView *_activityIndicatorView;
|
||||
}
|
||||
|
||||
- (void)reload:(id)sender {
|
||||
[_activityIndicatorView startAnimating];
|
||||
self.navigationItem.rightBarButtonItem.enabled = NO;
|
||||
|
||||
[Post globalTimelinePostsWithBlock:^(NSArray *posts, NSError *error) {
|
||||
if (error) {
|
||||
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:[error localizedDescription] delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"OK", nil), nil] show];
|
||||
} else {
|
||||
_posts = posts;
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
[_activityIndicatorView stopAnimating];
|
||||
self.navigationItem.rightBarButtonItem.enabled = YES;
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UIViewController
|
||||
|
||||
- (void)loadView {
|
||||
[super loadView];
|
||||
|
||||
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
|
||||
_activityIndicatorView.hidesWhenStopped = YES;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.title = NSLocalizedString(@"AFNetworking", nil);
|
||||
|
||||
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_activityIndicatorView];
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(reload:)];
|
||||
|
||||
self.tableView.rowHeight = 70.0f;
|
||||
|
||||
[self reload:nil];
|
||||
}
|
||||
|
||||
- (void)viewDidUnload {
|
||||
_activityIndicatorView = nil;
|
||||
|
||||
[super viewDidUnload];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDataSource
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return [_posts count];
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
static NSString *CellIdentifier = @"Cell";
|
||||
|
||||
PostTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
||||
if (!cell) {
|
||||
cell = [[PostTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
|
||||
}
|
||||
|
||||
cell.post = [_posts objectAtIndex:indexPath.row];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return [PostTableViewCell heightForCellWithPost:[_posts objectAtIndex:indexPath.row]];
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
// Post.h
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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>
|
||||
|
||||
@class User;
|
||||
|
||||
@interface Post : NSObject
|
||||
|
||||
@property (readonly) NSUInteger postID;
|
||||
@property (readonly) NSString *text;
|
||||
|
||||
@property (readonly) User *user;
|
||||
|
||||
- (id)initWithAttributes:(NSDictionary *)attributes;
|
||||
|
||||
+ (void)globalTimelinePostsWithBlock:(void (^)(NSArray *posts, NSError *error))block;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,68 @@
|
||||
// Post.m
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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 "Post.h"
|
||||
#import "User.h"
|
||||
|
||||
#import "AFAppDotNetAPIClient.h"
|
||||
|
||||
@implementation Post
|
||||
@synthesize postID = _postID;
|
||||
@synthesize text = _text;
|
||||
@synthesize user = _user;
|
||||
|
||||
- (id)initWithAttributes:(NSDictionary *)attributes {
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_postID = [[attributes valueForKeyPath:@"id"] integerValue];
|
||||
_text = [attributes valueForKeyPath:@"text"];
|
||||
|
||||
_user = [[User alloc] initWithAttributes:[attributes valueForKeyPath:@"user"]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
+ (void)globalTimelinePostsWithBlock:(void (^)(NSArray *posts, NSError *error))block {
|
||||
[[AFAppDotNetAPIClient sharedClient] getPath:@"stream/0/posts/stream/global" parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON) {
|
||||
NSArray *postsFromResponse = [JSON valueForKeyPath:@"data"];
|
||||
NSMutableArray *mutablePosts = [NSMutableArray arrayWithCapacity:[postsFromResponse count]];
|
||||
for (NSDictionary *attributes in postsFromResponse) {
|
||||
Post *post = [[Post alloc] initWithAttributes:attributes];
|
||||
[mutablePosts addObject:post];
|
||||
}
|
||||
|
||||
if (block) {
|
||||
block([NSArray arrayWithArray:mutablePosts], nil);
|
||||
}
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if (block) {
|
||||
block([NSArray array], error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,39 @@
|
||||
// User.h
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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 NSString * const kUserProfileImageDidLoadNotification;
|
||||
|
||||
@interface User : NSObject
|
||||
|
||||
@property (readonly) NSUInteger userID;
|
||||
@property (readonly) NSString *username;
|
||||
@property (unsafe_unretained, readonly) NSURL *avatarImageURL;
|
||||
|
||||
- (id)initWithAttributes:(NSDictionary *)attributes;
|
||||
|
||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
@property (nonatomic, strong) NSImage *profileImage;
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,97 @@
|
||||
// User.m
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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 "User.h"
|
||||
#import "AFImageRequestOperation.h"
|
||||
|
||||
NSString * const kUserProfileImageDidLoadNotification = @"com.alamofire.user.profile-image.loaded";
|
||||
|
||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
@interface User ()
|
||||
+ (NSOperationQueue *)sharedProfileImageRequestOperationQueue;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@implementation User {
|
||||
@private
|
||||
NSString *_avatarImageURLString;
|
||||
AFImageRequestOperation *_avatarImageRequestOperation;
|
||||
}
|
||||
|
||||
@synthesize userID = _userID;
|
||||
@synthesize username = _username;
|
||||
|
||||
- (id)initWithAttributes:(NSDictionary *)attributes {
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_userID = [[attributes valueForKeyPath:@"id"] integerValue];
|
||||
_username = [attributes valueForKeyPath:@"username"];
|
||||
_avatarImageURLString = [attributes valueForKeyPath:@"avatar_image.url"];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSURL *)avatarImageURL {
|
||||
return [NSURL URLWithString:_avatarImageURLString];
|
||||
}
|
||||
|
||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
|
||||
@synthesize profileImage = _profileImage;
|
||||
|
||||
+ (NSOperationQueue *)sharedProfileImageRequestOperationQueue {
|
||||
static NSOperationQueue *_sharedProfileImageRequestOperationQueue = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_sharedProfileImageRequestOperationQueue = [[NSOperationQueue alloc] init];
|
||||
[_sharedProfileImageRequestOperationQueue setMaxConcurrentOperationCount:8];
|
||||
});
|
||||
|
||||
return _sharedProfileImageRequestOperationQueue;
|
||||
}
|
||||
|
||||
- (NSImage *)profileImage {
|
||||
if (!_profileImage && !_avatarImageRequestOperation) {
|
||||
_avatarImageRequestOperation = [AFImageRequestOperation imageRequestOperationWithRequest:[NSURLRequest requestWithURL:self.avatarImageURL] success:^(NSImage *image) {
|
||||
self.profileImage = image;
|
||||
|
||||
_avatarImageRequestOperation = nil;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kUserProfileImageDidLoadNotification object:self userInfo:nil];
|
||||
}];
|
||||
|
||||
[_avatarImageRequestOperation setCacheResponseBlock:^NSCachedURLResponse *(NSURLConnection *connection, NSCachedURLResponse *cachedResponse) {
|
||||
return [[NSCachedURLResponse alloc] initWithResponse:cachedResponse.response data:cachedResponse.data userInfo:cachedResponse.userInfo storagePolicy:NSURLCacheStorageAllowed];
|
||||
}];
|
||||
|
||||
[[[self class] sharedProfileImageRequestOperationQueue] addOperation:_avatarImageRequestOperation];
|
||||
}
|
||||
|
||||
return _profileImage;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
// TweetTableViewCell.h
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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 <UIKit/UIKit.h>
|
||||
|
||||
@class Post;
|
||||
|
||||
@interface PostTableViewCell : UITableViewCell
|
||||
|
||||
@property (nonatomic, strong) Post *post;
|
||||
|
||||
+ (CGFloat)heightForCellWithPost:(Post *)post;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,81 @@
|
||||
// TweetTableViewCell.m
|
||||
//
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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 "PostTableViewCell.h"
|
||||
|
||||
#import "Post.h"
|
||||
#import "User.h"
|
||||
|
||||
#import "UIImageView+AFNetworking.h"
|
||||
|
||||
@implementation PostTableViewCell {
|
||||
@private
|
||||
__strong Post *_post;
|
||||
}
|
||||
|
||||
@synthesize post = _post;
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.textLabel.adjustsFontSizeToFitWidth = YES;
|
||||
self.textLabel.textColor = [UIColor darkGrayColor];
|
||||
self.detailTextLabel.font = [UIFont systemFontOfSize:12.0f];
|
||||
self.detailTextLabel.numberOfLines = 0;
|
||||
self.selectionStyle = UITableViewCellSelectionStyleGray;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setPost:(Post *)post {
|
||||
_post = post;
|
||||
|
||||
self.textLabel.text = _post.user.username;
|
||||
self.detailTextLabel.text = _post.text;
|
||||
[self.imageView setImageWithURL:_post.user.avatarImageURL placeholderImage:[UIImage imageNamed:@"profile-image-placeholder"]];
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
+ (CGFloat)heightForCellWithPost:(Post *)post {
|
||||
CGSize sizeToFit = [post.text sizeWithFont:[UIFont systemFontOfSize:12.0f] constrainedToSize:CGSizeMake(220.0f, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap];
|
||||
|
||||
return fmaxf(70.0f, sizeToFit.height + 45.0f);
|
||||
}
|
||||
|
||||
#pragma mark - UIView
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
|
||||
self.imageView.frame = CGRectMake(10.0f, 10.0f, 50.0f, 50.0f);
|
||||
self.textLabel.frame = CGRectMake(70.0f, 10.0f, 240.0f, 20.0f);
|
||||
|
||||
CGRect detailTextLabelFrame = CGRectOffset(self.textLabel.frame, 0.0f, 25.0f);
|
||||
detailTextLabelFrame.size.height = [[self class] heightForCellWithPost:_post] - 45.0f;
|
||||
self.detailTextLabel.frame = detailTextLabelFrame;
|
||||
}
|
||||
|
||||
@end
|
||||
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 942 B |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,34 @@
|
||||
<?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>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.alamofire.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2012年 Mattt Thompson. All rights reserved.</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,20 @@
|
||||
#import <Availability.h>
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
#ifndef __IPHONE_3_0
|
||||
#warning "This project uses features only available in iPhone SDK 3.0 and later."
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <SystemConfiguration/SystemConfiguration.h>
|
||||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <SystemConfiguration/SystemConfiguration.h>
|
||||
#import <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
<?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>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>AFNetworking</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>Icon.png</string>
|
||||
<string>Icon@2x.png</string>
|
||||
</array>
|
||||
<key>CFBundleIcons</key>
|
||||
<dict>
|
||||
<key>CFBundlePrimaryIcon</key>
|
||||
<dict>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>Icon.png</string>
|
||||
<string>Icon@2x.png</string>
|
||||
</array>
|
||||
<key>UIPrerenderedIcon</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.alamofire.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIPrerenderedIcon</key>
|
||||
<true/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<false/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,37 @@
|
||||
// main.m
|
||||
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
|
||||
//
|
||||
// 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.
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@autoreleasepool {
|
||||
int retVal = UIApplicationMain(argc, argv, @"UIApplication", @"AppDelegate");
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
return NSApplicationMain(argc, (const char **)argv);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
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.
|
||||
@@ -0,0 +1,179 @@
|
||||
<img src="https://github.com/AFNetworking/AFNetworking/raw/gh-pages/afnetworking-logo.png" alt="AFNetworking" title="AFNetworking" style="display:block; margin: 10px auto 30px auto;" class="center">
|
||||
|
||||
AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of [NSURLConnection](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html), [NSOperation](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html), and other familiar Foundation technologies. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. For example, here's how easy it is to get JSON from a URL:
|
||||
|
||||
``` objective-c
|
||||
NSURL *url = [NSURL URLWithString:@"https://alpha-api.app.net/stream/0/posts/stream/global"];
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:url];
|
||||
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
|
||||
NSLog(@"App.net Global Stream: %@", JSON);
|
||||
} failure:nil];
|
||||
[operation start];
|
||||
```
|
||||
|
||||
Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.
|
||||
|
||||
Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did!
|
||||
|
||||
## How To Get Started
|
||||
|
||||
- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/zipball/master) and try out the included Mac and iPhone example apps
|
||||
- Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles in the wiki](https://github.com/AFNetworking/AFNetworking/wiki)
|
||||
- Check out the [complete documentation](http://afnetworking.github.com/AFNetworking/) for a comprehensive look at the APIs available in AFNetworking
|
||||
- Watch the [NSScreencast episode about AFNetworking](http://nsscreencast.com/episodes/6-afnetworking) for a quick introduction to how to use it in your application
|
||||
- Questions? [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking) is the best place to find answers
|
||||
|
||||
## Overview
|
||||
|
||||
AFNetworking is architected to be as small and modular as possible, in order to make it simple to use and extend.
|
||||
|
||||
<table>
|
||||
<tr><th colspan="2" style="text-align:center;">Core</th></tr>
|
||||
<tr>
|
||||
<td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFURLConnectionOperation.html">AFURLConnectionOperation</a></td>
|
||||
<td>An <tt>NSOperation</tt> that implements the <tt>NSURLConnection</tt> delegate methods.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th colspan="2" style="text-align:center;">HTTP Requests</th></tr>
|
||||
|
||||
<tr>
|
||||
<td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFHTTPRequestOperation.html">AFHTTPRequestOperation</a></td>
|
||||
<td>A subclass of <tt>AFURLConnectionOperation</tt> for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFJSONRequestOperation.html">AFJSONRequestOperation</a></td>
|
||||
<td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and working with JSON response data.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFXMLRequestOperation.html">AFXMLRequestOperation</a></td>
|
||||
<td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and working with XML response data.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFPropertyListRequestOperation.html">AFPropertyListRequestOperation</a></td>
|
||||
<td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and deserializing objects with <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PropertyLists/index.html">property list</a> response data.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th colspan="2" style="text-align:center;">HTTP Client</th></tr>
|
||||
<tr>
|
||||
<td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFHTTPClient.html">AFHTTPClient</a></td>
|
||||
<td>
|
||||
Captures the common patterns of communicating with an web application over HTTP, including:
|
||||
|
||||
<ul>
|
||||
<li>Making requests from relative paths of a base URL</li>
|
||||
<li>Setting HTTP headers to be added automatically to requests</li>
|
||||
<li>Authenticating requests with HTTP Basic credentials or an OAuth token</li>
|
||||
<li>Managing an <tt>NSOperationQueue</tt> for requests made by the client</li>
|
||||
<li>Generating query strings or HTTP bodies from an <tt>NSDictionary</tt></li>
|
||||
<li>Constructing multipart form requests</li>
|
||||
<li>Automatically parsing HTTP response data into its corresponding object representation</li>
|
||||
<li>Monitoring and responding to changes in network reachability</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><th colspan="2" style="text-align:center;">Images</th></tr>
|
||||
<tr>
|
||||
<td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFImageRequestOperation.html">AFImageRequestOperation</a></td>
|
||||
<td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and processing images.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="http://afnetworking.github.com/AFNetworking/Categories/UIImageView+AFNetworking.html">UIImageView+AFNetworking</a></td>
|
||||
<td>Adds methods to <tt>UIImageView</tt> for loading remote images asynchronously from a URL.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Example Usage
|
||||
|
||||
### XML Request
|
||||
|
||||
``` objective-c
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://api.flickr.com/services/rest/?method=flickr.groups.browse&api_key=b6300e17ad3c506e706cb0072175d047&cat_id=34427469792%40N01&format=rest"]];
|
||||
AFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) {
|
||||
XMLParser.delegate = self;
|
||||
[XMLParser parse];
|
||||
} failure:nil];
|
||||
[operation start];
|
||||
```
|
||||
|
||||
### Image Request
|
||||
|
||||
``` objective-c
|
||||
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
|
||||
[imageView setImageWithURL:[NSURL URLWithString:@"http://i.imgur.com/r4uwx.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]];
|
||||
```
|
||||
|
||||
### API Client Request
|
||||
|
||||
``` objective-c
|
||||
// AFAppDotNetAPIClient is a subclass of AFHTTPClient, which defines the base URL and default HTTP headers for NSURLRequests it creates
|
||||
[[AFAppDotNetAPIClient sharedClient] getPath:@"stream/0/posts/stream/global" parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON) {
|
||||
NSLog(@"App.net Global Stream: %@", JSON);
|
||||
} failure:nil];
|
||||
```
|
||||
|
||||
### File Upload with Progress Callback
|
||||
|
||||
``` objective-c
|
||||
NSURL *url = [NSURL URLWithString:@"http://api-base-url.com"];
|
||||
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
|
||||
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"avatar.jpg"], 0.5);
|
||||
NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/upload" parameters:nil constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
|
||||
[formData appendPartWithFileData:imageData name:@"avatar" fileName:@"avatar.jpg" mimeType:@"image/jpeg"];
|
||||
}];
|
||||
|
||||
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
|
||||
[operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
|
||||
NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
|
||||
}];
|
||||
[operation start];
|
||||
```
|
||||
|
||||
### Streaming Request
|
||||
|
||||
``` objective-c
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:8080/encode"]];
|
||||
|
||||
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
|
||||
operation.inputStream = [NSInputStream inputStreamWithFileAtPath:[[NSBundle mainBundle] pathForResource:@"large-image" ofType:@"tiff"]];
|
||||
operation.outputStream = [NSOutputStream outputStreamToMemory];
|
||||
[operation start];
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
AFNetworking 1.0 and higher 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.
|
||||
|
||||
For compatibility with iOS 4.3, use the latest 0.10.x release.
|
||||
|
||||
### ARC
|
||||
|
||||
AFNetworking uses ARC as of its 1.0 release.
|
||||
|
||||
If you are using AFNetworking 1.0 in your non-arc project, you will need to set a `-fobjc-arc` compiler flag on all of the AFNetworking source files. Conversely, if you are adding a pre-1.0 version of AFNetworking, you will need to set a `-fno-objc-arc` compiler flag.
|
||||
|
||||
To set a compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Now select all AFNetworking source files, press Enter, insert `-fobjc-arc` or `-fno-objc-arc` and then "Done" to enable or disable ARC for AFNetworking.
|
||||
|
||||
## Credits
|
||||
|
||||
AFNetworking was created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla).
|
||||
|
||||
AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/).
|
||||
|
||||
And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors).
|
||||
|
||||
## Contact
|
||||
|
||||
Follow AFNetworking on Twitter ([@AFNetworking](https://twitter.com/AFNetworking))
|
||||
|
||||
### Creators
|
||||
|
||||
[Mattt Thompson](http://github.com/mattt)
|
||||
[@mattt](https://twitter.com/mattt)
|
||||
|
||||
[Scott Raymond](http://github.com/sco)
|
||||
[@sco](https://twitter.com/sco)
|
||||
|
||||
## License
|
||||
|
||||
AFNetworking is available under the MIT license. See the LICENSE file for more info.
|
||||
@@ -0,0 +1,34 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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 <SenTestingKit/SenTestingKit.h>
|
||||
|
||||
@interface AsyncSenTestCase : SenTestCase
|
||||
/** @note All the waitFor… methods run the current runloop while waiting to let other threads and operations to continue running **/
|
||||
-(void)waitForAsyncOperationWithTimeout:(NSTimeInterval)timeout; //!< Wait for one async operation
|
||||
-(void)waitForAsyncOperations:(NSUInteger)count withTimeout:(NSTimeInterval)timeout; //!< Wait for multiple async operations
|
||||
-(void)waitForTimeout:(NSTimeInterval)timeout; //!< Wait for a fixed amount of time
|
||||
-(void)notifyAsyncOperationDone; //!< notify any waiter that the async op is done
|
||||
@end
|
||||
@@ -0,0 +1,82 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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 "AsyncSenTestCase.h"
|
||||
|
||||
@interface AsyncSenTestCase()
|
||||
@property(atomic, assign) NSUInteger asyncTestCaseSignaledCount;
|
||||
@end
|
||||
|
||||
static const NSTimeInterval kRunLoopSamplingInterval = 0.01;
|
||||
|
||||
|
||||
|
||||
@implementation AsyncSenTestCase
|
||||
|
||||
@synthesize asyncTestCaseSignaledCount = _asyncTestCaseSignaledCount;
|
||||
|
||||
-(void)waitForAsyncOperationWithTimeout:(NSTimeInterval)timeout
|
||||
{
|
||||
[self waitForAsyncOperations:1 withTimeout:timeout];
|
||||
}
|
||||
|
||||
-(void)waitForAsyncOperations:(NSUInteger)count withTimeout:(NSTimeInterval)timeout
|
||||
{
|
||||
NSDate* timeoutDate = [NSDate dateWithTimeIntervalSinceNow:timeout];
|
||||
while ((self.asyncTestCaseSignaledCount < count) && ([timeoutDate timeIntervalSinceNow]>0))
|
||||
{
|
||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, kRunLoopSamplingInterval, YES);
|
||||
}
|
||||
|
||||
// Reset the counter for next time, in case we call this method again later
|
||||
// (don't reset it at the beginning of the method because we should be able to call
|
||||
// notifyAsyncOperationDone *before* this method if we wanted to)
|
||||
self.asyncTestCaseSignaledCount = 0;
|
||||
|
||||
if ([timeoutDate timeIntervalSinceNow]<0)
|
||||
{
|
||||
// now is after timeoutDate, we timed out
|
||||
STFail(@"Timed out while waiting for Async Operations to finish.");
|
||||
}
|
||||
}
|
||||
|
||||
-(void)waitForTimeout:(NSTimeInterval)timeout
|
||||
{
|
||||
NSDate* waitEndDate = [NSDate dateWithTimeIntervalSinceNow:timeout];
|
||||
while ([waitEndDate timeIntervalSinceNow]>0)
|
||||
{
|
||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, kRunLoopSamplingInterval, YES);
|
||||
}
|
||||
}
|
||||
|
||||
-(void)notifyAsyncOperationDone
|
||||
{
|
||||
@synchronized(self)
|
||||
{
|
||||
self.asyncTestCaseSignaledCount = self.asyncTestCaseSignaledCount+1;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,61 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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 "AsyncSenTestCase.h"
|
||||
#import "AFHTTPRequestOperation.h"
|
||||
#import "OHHTTPStubs.h"
|
||||
|
||||
@interface AFNetworkingTests : AsyncSenTestCase @end
|
||||
|
||||
@implementation AFNetworkingTests
|
||||
|
||||
-(void)test_AFHTTPRequestOperation
|
||||
{
|
||||
static const NSTimeInterval kResponseTime = 1.0;
|
||||
NSData* expectedResponse = [NSStringFromSelector(_cmd) dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
return YES;
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
return [OHHTTPStubsResponse responseWithData:expectedResponse statusCode:200 responseTime:kResponseTime headers:nil];
|
||||
}];
|
||||
|
||||
NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.iana.org/domains/example/"]];
|
||||
AFHTTPRequestOperation* op = [[[AFHTTPRequestOperation alloc] initWithRequest:req] autorelease];
|
||||
__block id response = nil;
|
||||
[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||
response = [[responseObject retain] autorelease];
|
||||
[self notifyAsyncOperationDone];
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
STFail(@"Unexpected network failure");
|
||||
[self notifyAsyncOperationDone];
|
||||
}];
|
||||
[op start];
|
||||
|
||||
[self waitForAsyncOperationWithTimeout:kResponseTime+0.5];
|
||||
|
||||
STAssertEqualObjects(response, expectedResponse, @"Unexpected data received");
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,228 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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 "AsyncSenTestCase.h"
|
||||
#import "OHHTTPStubs.h"
|
||||
|
||||
@interface NSURLConnectionDelegateTests : AsyncSenTestCase <NSURLConnectionDataDelegate> @end
|
||||
|
||||
static const NSTimeInterval kResponseTimeTolerence = 0.2;
|
||||
|
||||
@implementation NSURLConnectionDelegateTests
|
||||
{
|
||||
NSMutableData* _data;
|
||||
NSError* _error;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark Global Setup + NSURLConnectionDelegate implementation
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
-(void)setUp
|
||||
{
|
||||
[super setUp];
|
||||
_data = [[NSMutableData alloc] init];
|
||||
}
|
||||
|
||||
-(void)tearDown
|
||||
{
|
||||
[_data release];
|
||||
// in case the test timed out and finished before a running NSURLConnection ended,
|
||||
// we may continue receive delegate messages anyway if we forgot to cancel.
|
||||
// So avoid sending messages to deallocated object in this case by ensuring we reset it to nil
|
||||
_data = nil;
|
||||
[_error release];
|
||||
_error = nil;
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
|
||||
{
|
||||
[_data setLength:0U];
|
||||
}
|
||||
|
||||
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
|
||||
{
|
||||
[_data appendData:data];
|
||||
}
|
||||
|
||||
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
|
||||
{
|
||||
_error = [error retain];
|
||||
[self notifyAsyncOperationDone];
|
||||
}
|
||||
|
||||
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
|
||||
{
|
||||
[self notifyAsyncOperationDone];
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark NSURLConnection + Delegate
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
-(void)test_NSURLConnectionDelegate_success
|
||||
{
|
||||
static const NSTimeInterval kResponseTime = 1.0;
|
||||
NSData* testData = [NSStringFromSelector(_cmd) dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
return YES;
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
return [OHHTTPStubsResponse responseWithData:testData
|
||||
statusCode:200
|
||||
responseTime:kResponseTime
|
||||
headers:nil];
|
||||
}];
|
||||
|
||||
NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.iana.org/domains/example/"]];
|
||||
NSDate* startDate = [NSDate date];
|
||||
|
||||
NSURLConnection* cxn = [NSURLConnection connectionWithRequest:req delegate:self];
|
||||
|
||||
[self waitForAsyncOperationWithTimeout:kResponseTime+kResponseTimeTolerence];
|
||||
|
||||
STAssertEqualObjects(_data, testData, @"Invalid data response");
|
||||
STAssertNil(_error, @"Received unexpected network error %@", _error);
|
||||
STAssertEqualsWithAccuracy(-[startDate timeIntervalSinceNow], kResponseTime, kResponseTimeTolerence, @"Invalid response time");
|
||||
|
||||
// in case we timed out before the end of the request (test failed), cancel the request to avoid further delegate method calls
|
||||
[cxn cancel];
|
||||
}
|
||||
|
||||
-(void)test_NSURLConnectionDelegate_error
|
||||
{
|
||||
static const NSTimeInterval kResponseTime = 1.0;
|
||||
NSError* expectedError = [NSError errorWithDomain:NSURLErrorDomain code:404 userInfo:nil];
|
||||
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
return YES;
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
OHHTTPStubsResponse* resp = [OHHTTPStubsResponse responseWithError:expectedError];
|
||||
resp.responseTime = kResponseTime;
|
||||
return resp;
|
||||
}];
|
||||
|
||||
NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.iana.org/domains/example/"]];
|
||||
NSDate* startDate = [NSDate date];
|
||||
|
||||
NSURLConnection* cxn = [NSURLConnection connectionWithRequest:req delegate:self];
|
||||
|
||||
[self waitForAsyncOperationWithTimeout:kResponseTime+kResponseTimeTolerence];
|
||||
|
||||
STAssertEquals(_data.length, 0U, @"Received unexpected network data %@", _data);
|
||||
STAssertEqualObjects(_error.domain, expectedError.domain, @"Invalid error response domain");
|
||||
STAssertEquals(_error.code, expectedError.code, @"Invalid error response code");
|
||||
STAssertEqualsWithAccuracy(-[startDate timeIntervalSinceNow], kResponseTime, kResponseTimeTolerence, @"Invalid response time");
|
||||
|
||||
// in case we timed out before the end of the request (test failed), cancel the request to avoid further delegate method calls
|
||||
[cxn cancel];
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark Cancelling requests
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
-(void)test_NSURLConnection_cancel
|
||||
{
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
return YES;
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
return [OHHTTPStubsResponse responseWithData:[@"<this data should never have time to arrive>" dataUsingEncoding:NSUTF8StringEncoding]
|
||||
statusCode:500
|
||||
responseTime:1.5
|
||||
headers:nil];
|
||||
}];
|
||||
|
||||
NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.iana.org/domains/example/"]];
|
||||
NSURLConnection* cxn = [NSURLConnection connectionWithRequest:req delegate:self];
|
||||
|
||||
[self waitForTimeout:0.5];
|
||||
[cxn cancel];
|
||||
[self waitForTimeout:1.5];
|
||||
|
||||
STAssertEquals(_data.length, 0U, @"Received unexpected data but the request should have been cancelled");
|
||||
STAssertNil(_error, @"Received unexpected network error but the request should have been cancelled");
|
||||
|
||||
// in case we timed out before the end of the request (test failed), cancel the request to avoid further delegate method calls
|
||||
[cxn cancel];
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark Cancelling requests
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
-(void)test_NSURLConnection_cookies
|
||||
{
|
||||
NSString* const cookieName = @"SESSIONID";
|
||||
NSString* const cookieValue = [[NSProcessInfo processInfo] globallyUniqueString];
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
return YES;
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
NSString* cookie = [NSString stringWithFormat:@"%@=%@;", cookieName, cookieValue];
|
||||
NSDictionary* headers = [NSDictionary dictionaryWithObject:cookie forKey:@"Set-Cookie"];
|
||||
return [OHHTTPStubsResponse responseWithData:[@"Yummy cookies" dataUsingEncoding:NSUTF8StringEncoding]
|
||||
statusCode:200
|
||||
responseTime:0
|
||||
headers:headers];
|
||||
}];
|
||||
|
||||
// Set the cookie accept policy to accept all cookies from the main document domain
|
||||
// (especially in case the previous policy was "NSHTTPCookieAcceptPolicyNever")
|
||||
NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
|
||||
NSHTTPCookieAcceptPolicy previousAcceptPolicy = [cookieStorage cookieAcceptPolicy]; // keep it to restore later
|
||||
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain];
|
||||
|
||||
// Send the request and wait for the response containing the Set-Cookie headers
|
||||
NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.iana.org/domains/example/"]];
|
||||
NSURLConnection* cxn = [NSURLConnection connectionWithRequest:req delegate:self];
|
||||
[self waitForAsyncOperationWithTimeout:kResponseTimeTolerence];
|
||||
[cxn cancel]; // In case we timed out (test failed), cancel the request to avoid further delegate method calls
|
||||
|
||||
|
||||
/* Check that the cookie has been properly stored */
|
||||
NSArray* cookies = [cookieStorage cookiesForURL:req.URL];
|
||||
BOOL cookieFound = NO;
|
||||
for (NSHTTPCookie* cookie in cookies)
|
||||
{
|
||||
if ([cookie.name isEqualToString:cookieName])
|
||||
{
|
||||
cookieFound = YES;
|
||||
STAssertEqualObjects(cookie.value, cookieValue, @"The cookie does not have the expected value");
|
||||
}
|
||||
}
|
||||
STAssertTrue(cookieFound, @"The cookie was not stored as expected");
|
||||
|
||||
|
||||
// As a courtesy, restore previous policy before leaving
|
||||
[cookieStorage setCookieAcceptPolicy:previousAcceptPolicy];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,173 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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 "AsyncSenTestCase.h"
|
||||
#import "OHHTTPStubs.h"
|
||||
|
||||
@interface NSURLConnectionTests : AsyncSenTestCase @end
|
||||
|
||||
static const NSTimeInterval kResponseTimeTolerence = 0.2;
|
||||
|
||||
@implementation NSURLConnectionTests
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark [NSURLConnection sendSynchronousRequest:returningResponse:error:]
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
-(void)test_NSURLConnection_sendSyncronousRequest_mainQueue
|
||||
{
|
||||
static const NSTimeInterval kResponseTime = 1.0;
|
||||
NSData* testData = [NSStringFromSelector(_cmd) dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
return YES;
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
return [OHHTTPStubsResponse responseWithData:testData
|
||||
statusCode:200
|
||||
responseTime:kResponseTime
|
||||
headers:nil];
|
||||
}];
|
||||
|
||||
NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.iana.org/domains/example/"]];
|
||||
NSDate* startDate = [NSDate date];
|
||||
|
||||
NSData* data = [NSURLConnection sendSynchronousRequest:req returningResponse:NULL error:NULL];
|
||||
|
||||
STAssertEqualObjects(data, testData, @"Invalid data response");
|
||||
STAssertEqualsWithAccuracy(-[startDate timeIntervalSinceNow], kResponseTime, kResponseTimeTolerence, @"Invalid response time");
|
||||
}
|
||||
|
||||
-(void)test_NSURLConnection_sendSyncronousRequest_parallelQueue
|
||||
{
|
||||
[[[[NSOperationQueue alloc] init] autorelease] addOperationWithBlock:^{
|
||||
[self test_NSURLConnection_sendSyncronousRequest_mainQueue];
|
||||
[self notifyAsyncOperationDone];
|
||||
}];
|
||||
[self waitForAsyncOperationWithTimeout:3.0];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark Single [NSURLConnection sendAsynchronousRequest:queue:completionHandler:]
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
-(void)_test_NSURLConnection_sendAsyncronousRequest_onOperationQueue:(NSOperationQueue*)queue
|
||||
{
|
||||
static const NSTimeInterval kResponseTime = 1.0;
|
||||
NSData* testData = [NSStringFromSelector(_cmd) dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
return YES;
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
return [OHHTTPStubsResponse responseWithData:testData
|
||||
statusCode:200
|
||||
responseTime:kResponseTime
|
||||
headers:nil];
|
||||
}];
|
||||
|
||||
|
||||
NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.iana.org/domains/example/"]];
|
||||
NSDate* startDate = [NSDate date];
|
||||
|
||||
[NSURLConnection sendAsynchronousRequest:req queue:queue completionHandler:^(NSURLResponse* resp, NSData* data, NSError* error)
|
||||
{
|
||||
STAssertEqualObjects(data, testData, @"Invalid data response");
|
||||
STAssertEqualsWithAccuracy(-[startDate timeIntervalSinceNow], kResponseTime, kResponseTimeTolerence, @"Invalid response time");
|
||||
|
||||
[self notifyAsyncOperationDone];
|
||||
}];
|
||||
|
||||
[self waitForAsyncOperationWithTimeout:kResponseTime+kResponseTimeTolerence];
|
||||
}
|
||||
|
||||
|
||||
-(void)test_NSURLConnection_sendAsyncronousRequest_mainQueue
|
||||
{
|
||||
[self _test_NSURLConnection_sendAsyncronousRequest_onOperationQueue:[NSOperationQueue mainQueue]];
|
||||
}
|
||||
|
||||
|
||||
-(void)test_NSURLConnection_sendAsyncronousRequest_parallelQueue
|
||||
{
|
||||
[self _test_NSURLConnection_sendAsyncronousRequest_onOperationQueue:[[[NSOperationQueue alloc] init] autorelease]];
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark Multiple Parallel [NSURLConnection sendAsynchronousRequest:queue:completionHandler:]
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
-(void)_test_NSURLConnection_sendMultipleAsyncronousRequestsOnOperationQueue:(NSOperationQueue*)queue
|
||||
{
|
||||
NSData* (^dataForRequest)(NSURLRequest*) = ^(NSURLRequest* req) {
|
||||
return [[NSString stringWithFormat:@"<Response for URL %@>",req.URL.absoluteString] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
};
|
||||
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
return YES;
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
NSData* retData = dataForRequest(request);
|
||||
NSTimeInterval responseTime = [request.URL.lastPathComponent doubleValue];
|
||||
return [OHHTTPStubsResponse responseWithData:retData
|
||||
statusCode:200
|
||||
responseTime:responseTime
|
||||
headers:nil];
|
||||
}];
|
||||
|
||||
// Reusable code to send a request that will respond in the given response time
|
||||
void (^sendAsyncRequest)(NSTimeInterval) = ^(NSTimeInterval responseTime)
|
||||
{
|
||||
NSString* urlString = [NSString stringWithFormat:@"http://dummyrequest/concurrent/time/%f",responseTime];
|
||||
NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
|
||||
[SenTestLog testLogWithFormat:@"== Sending request %@\n", req];
|
||||
NSDate* startDate = [NSDate date];
|
||||
[NSURLConnection sendAsynchronousRequest:req queue:queue completionHandler:^(NSURLResponse* resp, NSData* data, NSError* error)
|
||||
{
|
||||
[SenTestLog testLogWithFormat:@"== Received response for request %@\n", req];
|
||||
STAssertEqualObjects(data, dataForRequest(req), @"Invalid data response");
|
||||
STAssertEqualsWithAccuracy(-[startDate timeIntervalSinceNow], responseTime, kResponseTimeTolerence, @"Invalid response time");
|
||||
|
||||
[self notifyAsyncOperationDone];
|
||||
}];
|
||||
};
|
||||
|
||||
sendAsyncRequest(1.5); // send this one first, should receive last
|
||||
sendAsyncRequest(1.0); // send this one next, shoud receive 2nd
|
||||
sendAsyncRequest(0.5); // send this one last, should receive first
|
||||
|
||||
[self waitForAsyncOperations:3 withTimeout:2.0]; // time out after 4s because the requests should run concurrently and all should be done in ~1.5s
|
||||
}
|
||||
|
||||
-(void)test_NSURLConnection_sendMultipleAsyncronousRequests_mainQueue
|
||||
{
|
||||
[self _test_NSURLConnection_sendMultipleAsyncronousRequestsOnOperationQueue:[NSOperationQueue mainQueue]];
|
||||
}
|
||||
|
||||
-(void)test_NSURLConnection_sendMultipleAsyncronousRequests_parallelQueue
|
||||
{
|
||||
[self _test_NSURLConnection_sendMultipleAsyncronousRequestsOnOperationQueue:[[[NSOperationQueue alloc] init] autorelease]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,110 @@
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012 Olivier Halligon
|
||||
*
|
||||
* 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 "AsyncSenTestCase.h"
|
||||
#import "OHHTTPStubs.h"
|
||||
|
||||
@interface WithContentsOfURLTests : AsyncSenTestCase @end
|
||||
|
||||
static const NSTimeInterval kResponseTimeTolerence = 0.2;
|
||||
|
||||
@implementation WithContentsOfURLTests
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark [NSString stringWithContentsOfURL:encoding:error:]
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
-(void)test_NSString_stringWithContentsOfURL_mainQueue
|
||||
{
|
||||
static const NSTimeInterval kResponseTime = 1.0;
|
||||
NSString* testString = NSStringFromSelector(_cmd);
|
||||
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
return YES;
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
return [OHHTTPStubsResponse responseWithData:[testString dataUsingEncoding:NSUTF8StringEncoding]
|
||||
statusCode:200
|
||||
responseTime:kResponseTime
|
||||
headers:nil];
|
||||
}];
|
||||
|
||||
NSDate* startDate = [NSDate date];
|
||||
|
||||
NSString* string = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.iana.org/domains/example/"]
|
||||
encoding:NSUTF8StringEncoding
|
||||
error:NULL];
|
||||
|
||||
STAssertEqualObjects(string, testString, @"Invalid returned string");
|
||||
STAssertEqualsWithAccuracy(-[startDate timeIntervalSinceNow], kResponseTime, kResponseTimeTolerence, @"Invalid response time");
|
||||
}
|
||||
|
||||
-(void)test_NSString_stringWithContentsOfURL_parallelQueue
|
||||
{
|
||||
[[[[NSOperationQueue alloc] init] autorelease] addOperationWithBlock:^{
|
||||
[self test_NSString_stringWithContentsOfURL_mainQueue];
|
||||
[self notifyAsyncOperationDone];
|
||||
}];
|
||||
[self waitForAsyncOperationWithTimeout:3.0];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark [NSData dataWithContentsOfURL:]
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
-(void)test_NSData_dataWithContentsOfURL_mainQueue
|
||||
{
|
||||
static const NSTimeInterval kResponseTime = 1.0;
|
||||
NSData* testData = [NSStringFromSelector(_cmd) dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
return YES;
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
return [OHHTTPStubsResponse responseWithData:testData
|
||||
statusCode:200
|
||||
responseTime:kResponseTime
|
||||
headers:nil];
|
||||
}];
|
||||
|
||||
NSDate* startDate = [NSDate date];
|
||||
|
||||
NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.iana.org/domains/example/"]];
|
||||
|
||||
STAssertEqualObjects(data, testData, @"Invalid returned string");
|
||||
STAssertEqualsWithAccuracy(-[startDate timeIntervalSinceNow], kResponseTime, kResponseTimeTolerence, @"Invalid response time");
|
||||
}
|
||||
|
||||
-(void)test_NSData_dataWithContentsOfURL_parallelQueue
|
||||
{
|
||||
[[[[NSOperationQueue alloc] init] autorelease] addOperationWithBlock:^{
|
||||
[self test_NSData_dataWithContentsOfURL_mainQueue];
|
||||
[self notifyAsyncOperationDone];
|
||||
}];
|
||||
[self waitForAsyncOperationWithTimeout:3.0];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.alisoftware.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,7 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'OHHTTPStubs Unit Tests' target in the 'OHHTTPStubs Unit Tests' project
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "container:OHHTTPStubsDemo/OHHTTPStubsDemo.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "container:OHHTTPStubs/OHHTTPStubs.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?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>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
After Width: | Height: | Size: 18 KiB |
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// MainViewController.h
|
||||
// OHHTTPStubsDemo
|
||||
//
|
||||
// Created by Olivier Halligon on 11/08/12.
|
||||
// Copyright (c) 2012 AliSoftware. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MainViewController : UIViewController
|
||||
- (IBAction)toggleStubs:(UISwitch*)sender;
|
||||
- (IBAction)downloadText:(UIButton*)sender;
|
||||
- (IBAction)installTextStub:(UISwitch*)sender;
|
||||
- (IBAction)downloadImage:(UIButton*)sender;
|
||||
- (IBAction)installImageStub:(UISwitch*)sender;
|
||||
- (IBAction)clearResults;
|
||||
|
||||
@property (retain, nonatomic) IBOutlet UISwitch *delaySwitch;
|
||||
@property (retain, nonatomic) IBOutlet UITextView *textView;
|
||||
@property (retain, nonatomic) IBOutlet UISwitch *installTextStubSwitch;
|
||||
@property (retain, nonatomic) IBOutlet UIImageView *imageView;
|
||||
@property (retain, nonatomic) IBOutlet UISwitch *installImageStubSwitch;
|
||||
@end
|
||||
@@ -0,0 +1,171 @@
|
||||
//
|
||||
// MainViewController.m
|
||||
// OHHTTPStubsDemo
|
||||
//
|
||||
// Created by Olivier Halligon on 11/08/12.
|
||||
// Copyright (c) 2012 AliSoftware. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MainViewController.h"
|
||||
#import <OHHTTPStubs/OHHTTPStubs.h>
|
||||
|
||||
|
||||
@implementation MainViewController
|
||||
// IBOutlets
|
||||
@synthesize delaySwitch = _delaySwitch;
|
||||
@synthesize textView = _textView;
|
||||
@synthesize installTextStubSwitch = _installTextStubSwitch;
|
||||
@synthesize installImageStubSwitch = _installImageStubSwitch;
|
||||
@synthesize imageView = _imageView;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Init & Dealloc
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
#if ! __has_feature(objc_arc)
|
||||
[_textView release];
|
||||
[_imageView release];
|
||||
[_delaySwitch release];
|
||||
[_installTextStubSwitch release];
|
||||
[_installImageStubSwitch release];
|
||||
[super dealloc];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self installTextStub:self.installTextStubSwitch];
|
||||
[self installImageStub:self.installImageStubSwitch];
|
||||
}
|
||||
- (void)viewDidUnload
|
||||
{
|
||||
[self setTextView:nil];
|
||||
[self setImageView:nil];
|
||||
[self setDelaySwitch:nil];
|
||||
[super viewDidUnload];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Global stubs activation
|
||||
|
||||
- (IBAction)toggleStubs:(UISwitch *)sender
|
||||
{
|
||||
[OHHTTPStubs setEnabled:sender.on];
|
||||
self.delaySwitch.enabled = sender.on;
|
||||
self.installTextStubSwitch.enabled = sender.on;
|
||||
self.installImageStubSwitch.enabled = sender.on;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Text Download and Stub
|
||||
|
||||
|
||||
- (IBAction)downloadText:(UIButton*)sender
|
||||
{
|
||||
sender.enabled = NO;
|
||||
|
||||
NSString* urlString = @"http://www.loremipsum.de/downloads/version3.txt";
|
||||
NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
|
||||
|
||||
// This is a very handy way to send an asynchronous method, but only available in iOS5+
|
||||
[NSURLConnection sendAsynchronousRequest:req
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
completionHandler:^(NSURLResponse* resp, NSData* data, NSError* error)
|
||||
{
|
||||
sender.enabled = YES;
|
||||
NSString* receivedText = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
||||
self.textView.text = receivedText;
|
||||
#if ! __has_feature(objc_arc)
|
||||
[receivedText release];
|
||||
#endif
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
- (IBAction)installTextStub:(UISwitch *)sender
|
||||
{
|
||||
static id textHandler = nil; // Note: no need to retain this value, it is retained by the OHHTTPStubs itself already :)
|
||||
|
||||
if (sender.on)
|
||||
{
|
||||
// Install
|
||||
textHandler = [OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
// This handler will only configure stub requests for "*.txt" files
|
||||
return [request.URL.absoluteString.pathExtension isEqualToString:@"txt"];
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
// Stub txt files with this
|
||||
return [OHHTTPStubsResponse responseWithFile:@"stub.txt"
|
||||
contentType:@"text/plain"
|
||||
responseTime:self.delaySwitch.on ? 2.f: 0.f];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Uninstall
|
||||
[OHHTTPStubs removeRequestHandler:textHandler];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Image Download and Stub
|
||||
|
||||
- (IBAction)downloadImage:(UIButton*)sender
|
||||
{
|
||||
sender.enabled = NO;
|
||||
|
||||
NSString* urlString = @"http://images.apple.com/iphone/ios/images/ios_business_2x.jpg";
|
||||
NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
|
||||
|
||||
// This is a very handy way to send an asynchronous method, but only available in iOS5+
|
||||
[NSURLConnection sendAsynchronousRequest:req
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
completionHandler:^(NSURLResponse* resp, NSData* data, NSError* error)
|
||||
{
|
||||
sender.enabled = YES;
|
||||
self.imageView.image = [UIImage imageWithData:data];
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)installImageStub:(UISwitch *)sender
|
||||
{
|
||||
static id imageHandler = nil; // Note: no need to retain this value, it is retained by the OHHTTPStubs itself already :)
|
||||
if (sender.on)
|
||||
{
|
||||
// Install
|
||||
imageHandler = [OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
// This handler will only configure stub requests for "*.jpg" files
|
||||
return [request.URL.absoluteString.pathExtension isEqualToString:@"jpg"];
|
||||
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
|
||||
// Stub jpg files with this
|
||||
return [OHHTTPStubsResponse responseWithFile:@"stub.jpg"
|
||||
contentType:@"image/jpeg"
|
||||
responseTime:self.delaySwitch.on ? 2.f: 0.f];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Uninstall
|
||||
[OHHTTPStubs removeRequestHandler:imageHandler];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Cleaning
|
||||
|
||||
- (IBAction)clearResults
|
||||
{
|
||||
self.textView.text = @"";
|
||||
self.imageView.image = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,725 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1296</int>
|
||||
<string key="IBDocument.SystemVersion">11E53</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">2549</string>
|
||||
<string key="IBDocument.AppKitVersion">1138.47</string>
|
||||
<string key="IBDocument.HIToolboxVersion">569.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="NS.object.0">1498</string>
|
||||
</object>
|
||||
<array key="IBDocument.IntegratedClassDependencies">
|
||||
<string>IBProxyObject</string>
|
||||
<string>IBUIButton</string>
|
||||
<string>IBUIImageView</string>
|
||||
<string>IBUILabel</string>
|
||||
<string>IBUISwitch</string>
|
||||
<string>IBUITextView</string>
|
||||
<string>IBUIView</string>
|
||||
<string>IBUIViewController</string>
|
||||
<string>IBUIWindow</string>
|
||||
</array>
|
||||
<array key="IBDocument.PluginDependencies">
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</array>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
|
||||
<integer value="1" key="NS.object.0"/>
|
||||
</object>
|
||||
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||
<object class="IBProxyObject" id="372490531">
|
||||
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBProxyObject" id="975951072">
|
||||
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUIWindow" id="274827769">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrameSize">{320, 480}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<object class="NSColor" key="IBUIBackgroundColor" id="956122546">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MSAxIDEAA</bytes>
|
||||
</object>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<bool key="IBUIVisibleAtLaunch">YES</bool>
|
||||
<bool key="IBUIResizesToFullScreen">YES</bool>
|
||||
</object>
|
||||
<object class="IBUIViewController" id="264210514">
|
||||
<object class="IBUIView" key="IBUIView" id="191373211">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<array class="NSMutableArray" key="NSSubviews">
|
||||
<object class="IBUIButton" id="33517639">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 110}, {176, 37}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="256487978"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<int key="IBUIButtonType">1</int>
|
||||
<string key="IBUIDisabledTitle">Downloading…</string>
|
||||
<string key="IBUINormalTitle">Download some text</string>
|
||||
<object class="NSColor" key="IBUIHighlightedTitleColor" id="730109619">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
<object class="NSColor" key="IBUIDisabledTitleColor" id="252948466">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
|
||||
</object>
|
||||
<object class="NSColor" key="IBUINormalTitleColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
|
||||
</object>
|
||||
<object class="NSColor" key="IBUINormalTitleShadowColor" id="1010867727">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC41AA</bytes>
|
||||
</object>
|
||||
<object class="IBUIFontDescription" key="IBUIFontDescription" id="201183604">
|
||||
<int key="type">2</int>
|
||||
<double key="pointSize">15</double>
|
||||
</object>
|
||||
<object class="NSFont" key="IBUIFont" id="955733942">
|
||||
<string key="NSName">Helvetica-Bold</string>
|
||||
<double key="NSSize">15</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBUISwitch" id="855492565">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{206, 17}, {94, 27}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="672668238"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<bool key="IBUIOn">YES</bool>
|
||||
</object>
|
||||
<object class="IBUITextView" id="470940424">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 155}, {280, 92}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="972190539"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<reference key="IBUIBackgroundColor" ref="956122546"/>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<bool key="IBUIMultipleTouchEnabled">YES</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<bool key="IBUIEditable">NO</bool>
|
||||
<string key="IBUIText"/>
|
||||
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
|
||||
<int key="IBUIAutocapitalizationType">2</int>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUIFontDescription" key="IBUIFontDescription">
|
||||
<int key="type">1</int>
|
||||
<double key="pointSize">14</double>
|
||||
</object>
|
||||
<object class="NSFont" key="IBUIFont">
|
||||
<string key="NSName">Helvetica</string>
|
||||
<double key="NSSize">14</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBUILabel" id="132004535">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 20}, {177, 21}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="855492565"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<int key="IBUIContentMode">7</int>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<string key="IBUIText">Activate Stubs Globally</string>
|
||||
<object class="NSColor" key="IBUITextColor" id="532830748">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MCAwIDAAA</bytes>
|
||||
</object>
|
||||
<nil key="IBUIHighlightedColor"/>
|
||||
<int key="IBUIBaselineAdjustment">0</int>
|
||||
<float key="IBUIMinimumFontSize">10</float>
|
||||
<object class="IBUIFontDescription" key="IBUIFontDescription" id="402469275">
|
||||
<int key="type">1</int>
|
||||
<double key="pointSize">17</double>
|
||||
</object>
|
||||
<object class="NSFont" key="IBUIFont" id="644845447">
|
||||
<string key="NSName">Helvetica</string>
|
||||
<double key="NSSize">17</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBUIButton" id="972190539">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 255}, {176, 37}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="752920139"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<int key="IBUIButtonType">1</int>
|
||||
<string key="IBUIDisabledTitle">Downloading…</string>
|
||||
<string key="IBUINormalTitle">Download image</string>
|
||||
<reference key="IBUIHighlightedTitleColor" ref="730109619"/>
|
||||
<reference key="IBUIDisabledTitleColor" ref="252948466"/>
|
||||
<object class="NSColor" key="IBUINormalTitleColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
|
||||
</object>
|
||||
<reference key="IBUINormalTitleShadowColor" ref="1010867727"/>
|
||||
<reference key="IBUIFontDescription" ref="201183604"/>
|
||||
<reference key="IBUIFont" ref="955733942"/>
|
||||
</object>
|
||||
<object class="IBUIImageView" id="809726651">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 300}, {280, 140}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<int key="IBUIContentMode">1</int>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUILabel" id="672668238">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 55}, {109, 21}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="381299425"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<int key="IBUIContentMode">7</int>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<string key="IBUIText">Fake 2s Delay</string>
|
||||
<reference key="IBUITextColor" ref="532830748"/>
|
||||
<nil key="IBUIHighlightedColor"/>
|
||||
<int key="IBUIBaselineAdjustment">0</int>
|
||||
<float key="IBUIMinimumFontSize">10</float>
|
||||
<reference key="IBUIFontDescription" ref="402469275"/>
|
||||
<reference key="IBUIFont" ref="644845447"/>
|
||||
</object>
|
||||
<object class="IBUISwitch" id="381299425">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{129, 52}, {94, 27}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="221495597"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
</object>
|
||||
<object class="IBUIButton" id="221495597">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{231, 49}, {69, 35}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="33517639"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<int key="IBUIButtonType">1</int>
|
||||
<string key="IBUINormalTitle">Clear</string>
|
||||
<reference key="IBUIHighlightedTitleColor" ref="730109619"/>
|
||||
<object class="NSColor" key="IBUINormalTitleColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
|
||||
</object>
|
||||
<reference key="IBUINormalTitleShadowColor" ref="1010867727"/>
|
||||
<reference key="IBUIFontDescription" ref="201183604"/>
|
||||
<reference key="IBUIFont" ref="955733942"/>
|
||||
</object>
|
||||
<object class="IBUISwitch" id="585740730">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{206, 120}, {94, 27}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="470940424"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<bool key="IBUIOn">YES</bool>
|
||||
</object>
|
||||
<object class="IBUISwitch" id="364379085">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{206, 265}, {94, 27}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="809726651"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<bool key="IBUIOn">YES</bool>
|
||||
</object>
|
||||
<object class="IBUILabel" id="256487978">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{221, 100}, {79, 21}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="585740730"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<int key="IBUIContentMode">7</int>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<string key="IBUIText">Stub installed?</string>
|
||||
<reference key="IBUITextColor" ref="532830748"/>
|
||||
<nil key="IBUIHighlightedColor"/>
|
||||
<int key="IBUIBaselineAdjustment">0</int>
|
||||
<float key="IBUIMinimumFontSize">10</float>
|
||||
<int key="IBUITextAlignment">1</int>
|
||||
<object class="IBUIFontDescription" key="IBUIFontDescription" id="236539325">
|
||||
<int key="type">1</int>
|
||||
<double key="pointSize">9</double>
|
||||
</object>
|
||||
<object class="NSFont" key="IBUIFont" id="760174175">
|
||||
<string key="NSName">Helvetica</string>
|
||||
<double key="NSSize">9</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
|
||||
</object>
|
||||
<object class="IBUILabel" id="752920139">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{221, 245}, {79, 21}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="364379085"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<int key="IBUIContentMode">7</int>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<string key="IBUIText">Stub installed?</string>
|
||||
<reference key="IBUITextColor" ref="532830748"/>
|
||||
<nil key="IBUIHighlightedColor"/>
|
||||
<int key="IBUIBaselineAdjustment">0</int>
|
||||
<float key="IBUIMinimumFontSize">10</float>
|
||||
<int key="IBUITextAlignment">1</int>
|
||||
<reference key="IBUIFontDescription" ref="236539325"/>
|
||||
<reference key="IBUIFont" ref="760174175"/>
|
||||
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
|
||||
</object>
|
||||
</array>
|
||||
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="132004535"/>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
<object class="NSColorSpace" key="NSCustomColorSpace">
|
||||
<int key="NSID">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
|
||||
<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
|
||||
<int key="IBUIInterfaceOrientation">1</int>
|
||||
<int key="interfaceOrientation">1</int>
|
||||
</object>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<bool key="IBUIHorizontal">NO</bool>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<array class="NSMutableArray" key="connectionRecords">
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">downloadText:</string>
|
||||
<reference key="source" ref="33517639"/>
|
||||
<reference key="destination" ref="264210514"/>
|
||||
<int key="IBEventType">7</int>
|
||||
</object>
|
||||
<int key="connectionID">32</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">toggleStubs:</string>
|
||||
<reference key="source" ref="855492565"/>
|
||||
<reference key="destination" ref="264210514"/>
|
||||
<int key="IBEventType">13</int>
|
||||
</object>
|
||||
<int key="connectionID">23</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">downloadImage:</string>
|
||||
<reference key="source" ref="972190539"/>
|
||||
<reference key="destination" ref="264210514"/>
|
||||
<int key="IBEventType">7</int>
|
||||
</object>
|
||||
<int key="connectionID">33</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">rootViewController</string>
|
||||
<reference key="source" ref="274827769"/>
|
||||
<reference key="destination" ref="264210514"/>
|
||||
</object>
|
||||
<int key="connectionID">22</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">textView</string>
|
||||
<reference key="source" ref="264210514"/>
|
||||
<reference key="destination" ref="470940424"/>
|
||||
</object>
|
||||
<int key="connectionID">24</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">imageView</string>
|
||||
<reference key="source" ref="264210514"/>
|
||||
<reference key="destination" ref="809726651"/>
|
||||
</object>
|
||||
<int key="connectionID">25</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">delaySwitch</string>
|
||||
<reference key="source" ref="264210514"/>
|
||||
<reference key="destination" ref="381299425"/>
|
||||
</object>
|
||||
<int key="connectionID">26</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">installTextStubSwitch</string>
|
||||
<reference key="source" ref="264210514"/>
|
||||
<reference key="destination" ref="585740730"/>
|
||||
</object>
|
||||
<int key="connectionID">47</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">installImageStubSwitch</string>
|
||||
<reference key="source" ref="264210514"/>
|
||||
<reference key="destination" ref="364379085"/>
|
||||
</object>
|
||||
<int key="connectionID">48</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">clearResults</string>
|
||||
<reference key="source" ref="221495597"/>
|
||||
<reference key="destination" ref="264210514"/>
|
||||
<int key="IBEventType">7</int>
|
||||
</object>
|
||||
<int key="connectionID">31</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">installTextStub:</string>
|
||||
<reference key="source" ref="585740730"/>
|
||||
<reference key="destination" ref="264210514"/>
|
||||
<int key="IBEventType">13</int>
|
||||
</object>
|
||||
<int key="connectionID">45</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">installImageStub:</string>
|
||||
<reference key="source" ref="364379085"/>
|
||||
<reference key="destination" ref="264210514"/>
|
||||
<int key="IBEventType">13</int>
|
||||
</object>
|
||||
<int key="connectionID">46</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<array key="object" id="0"/>
|
||||
<reference key="children" ref="1000"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="372490531"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="975951072"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">20</int>
|
||||
<reference key="object" ref="274827769"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">21</int>
|
||||
<reference key="object" ref="264210514"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="191373211"/>
|
||||
</array>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1</int>
|
||||
<reference key="object" ref="191373211"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="809726651"/>
|
||||
<reference ref="132004535"/>
|
||||
<reference ref="972190539"/>
|
||||
<reference ref="470940424"/>
|
||||
<reference ref="33517639"/>
|
||||
<reference ref="672668238"/>
|
||||
<reference ref="381299425"/>
|
||||
<reference ref="221495597"/>
|
||||
<reference ref="855492565"/>
|
||||
<reference ref="585740730"/>
|
||||
<reference ref="364379085"/>
|
||||
<reference ref="256487978"/>
|
||||
<reference ref="752920139"/>
|
||||
</array>
|
||||
<reference key="parent" ref="264210514"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">17</int>
|
||||
<reference key="object" ref="381299425"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">15</int>
|
||||
<reference key="object" ref="672668238"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">5</int>
|
||||
<reference key="object" ref="855492565"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">9</int>
|
||||
<reference key="object" ref="809726651"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">8</int>
|
||||
<reference key="object" ref="972190539"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">6</int>
|
||||
<reference key="object" ref="470940424"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">4</int>
|
||||
<reference key="object" ref="33517639"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">7</int>
|
||||
<reference key="object" ref="132004535"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">29</int>
|
||||
<reference key="object" ref="221495597"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">41</int>
|
||||
<reference key="object" ref="585740730"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">42</int>
|
||||
<reference key="object" ref="364379085"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">43</int>
|
||||
<reference key="object" ref="256487978"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">44</int>
|
||||
<reference key="object" ref="752920139"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
<string key="-1.CustomClassName">UIApplication</string>
|
||||
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="-2.CustomClassName">UIResponder</string>
|
||||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="15.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="17.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="20.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="21.CustomClassName">MainViewController</string>
|
||||
<string key="21.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="29.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<real value="0.0" key="4.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
|
||||
<string key="41.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="42.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="43.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="44.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="7.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="8.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<real value="3" key="8.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
|
||||
<string key="9.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">48</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">MainViewController</string>
|
||||
<string key="superclassName">UIViewController</string>
|
||||
<dictionary class="NSMutableDictionary" key="actions">
|
||||
<string key="clearResults">id</string>
|
||||
<string key="downloadImage:">UIButton</string>
|
||||
<string key="downloadText:">UIButton</string>
|
||||
<string key="installImageStub:">UISwitch</string>
|
||||
<string key="installTextStub:">UISwitch</string>
|
||||
<string key="toggleStubs:">UISwitch</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="actionInfosByName">
|
||||
<object class="IBActionInfo" key="clearResults">
|
||||
<string key="name">clearResults</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="downloadImage:">
|
||||
<string key="name">downloadImage:</string>
|
||||
<string key="candidateClassName">UIButton</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="downloadText:">
|
||||
<string key="name">downloadText:</string>
|
||||
<string key="candidateClassName">UIButton</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="installImageStub:">
|
||||
<string key="name">installImageStub:</string>
|
||||
<string key="candidateClassName">UISwitch</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="installTextStub:">
|
||||
<string key="name">installTextStub:</string>
|
||||
<string key="candidateClassName">UISwitch</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="toggleStubs:">
|
||||
<string key="name">toggleStubs:</string>
|
||||
<string key="candidateClassName">UISwitch</string>
|
||||
</object>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="outlets">
|
||||
<string key="delaySwitch">UISwitch</string>
|
||||
<string key="imageView">UIImageView</string>
|
||||
<string key="installImageStubButton">UIButton</string>
|
||||
<string key="installImageStubSwitch">UISwitch</string>
|
||||
<string key="installTextStubButton">UIButton</string>
|
||||
<string key="installTextStubSwitch">UISwitch</string>
|
||||
<string key="textView">UITextView</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<object class="IBToOneOutletInfo" key="delaySwitch">
|
||||
<string key="name">delaySwitch</string>
|
||||
<string key="candidateClassName">UISwitch</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="imageView">
|
||||
<string key="name">imageView</string>
|
||||
<string key="candidateClassName">UIImageView</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="installImageStubButton">
|
||||
<string key="name">installImageStubButton</string>
|
||||
<string key="candidateClassName">UIButton</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="installImageStubSwitch">
|
||||
<string key="name">installImageStubSwitch</string>
|
||||
<string key="candidateClassName">UISwitch</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="installTextStubButton">
|
||||
<string key="name">installTextStubButton</string>
|
||||
<string key="candidateClassName">UIButton</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="installTextStubSwitch">
|
||||
<string key="name">installTextStubSwitch</string>
|
||||
<string key="candidateClassName">UISwitch</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="textView">
|
||||
<string key="name">textView</string>
|
||||
<string key="candidateClassName">UITextView</string>
|
||||
</object>
|
||||
</dictionary>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/MainViewController.h</string>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
|
||||
<real value="1296" key="NS.object.0"/>
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
<string key="IBCocoaTouchPluginVersion">1498</string>
|
||||
</data>
|
||||
</archive>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.alisoftware.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainViewController</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'OHHTTPStubsDemo' target in the 'OHHTTPStubsDemo' project
|
||||
//
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
#ifndef __IPHONE_3_0
|
||||
#warning "This project uses features only available in iOS SDK 3.0 and later."
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
@@ -0,0 +1,282 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
097935A2161B654E006DB5D5 /* libOHHTTPStubs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 097935A1161B654E006DB5D5 /* libOHHTTPStubs.a */; };
|
||||
098FBDD415D704E800623941 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 098FBDD315D704E800623941 /* UIKit.framework */; };
|
||||
098FBDD615D704E800623941 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 098FBDD515D704E800623941 /* Foundation.framework */; };
|
||||
098FBDD815D704E800623941 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 098FBDD715D704E800623941 /* CoreGraphics.framework */; };
|
||||
098FBDE015D704E800623941 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 098FBDDF15D704E800623941 /* main.m */; };
|
||||
098FBDED15D7056200623941 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 098FBDEB15D7056200623941 /* MainViewController.m */; };
|
||||
098FBDEE15D7056200623941 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 098FBDEC15D7056200623941 /* MainViewController.xib */; };
|
||||
098FBDF815D70E2600623941 /* stub.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 098FBDF615D70E2600623941 /* stub.jpg */; };
|
||||
098FBDF915D70E2600623941 /* stub.txt in Resources */ = {isa = PBXBuildFile; fileRef = 098FBDF715D70E2600623941 /* stub.txt */; };
|
||||
099C7343169016D800239880 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 099C7342169016D800239880 /* Default-568h@2x.png */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
097935A1161B654E006DB5D5 /* libOHHTTPStubs.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libOHHTTPStubs.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
098FBDCF15D704E800623941 /* OHHTTPStubsDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OHHTTPStubsDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
098FBDD315D704E800623941 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
098FBDD515D704E800623941 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
098FBDD715D704E800623941 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
098FBDDB15D704E800623941 /* OHHTTPStubsDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OHHTTPStubsDemo-Info.plist"; sourceTree = "<group>"; };
|
||||
098FBDDF15D704E800623941 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
098FBDE115D704E800623941 /* OHHTTPStubsDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OHHTTPStubsDemo-Prefix.pch"; sourceTree = "<group>"; };
|
||||
098FBDEA15D7056200623941 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
|
||||
098FBDEB15D7056200623941 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
|
||||
098FBDEC15D7056200623941 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainViewController.xib; sourceTree = "<group>"; };
|
||||
098FBDF615D70E2600623941 /* stub.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = stub.jpg; sourceTree = "<group>"; };
|
||||
098FBDF715D70E2600623941 /* stub.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = stub.txt; sourceTree = "<group>"; };
|
||||
099C7342169016D800239880 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
098FBDCC15D704E800623941 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
097935A2161B654E006DB5D5 /* libOHHTTPStubs.a in Frameworks */,
|
||||
098FBDD415D704E800623941 /* UIKit.framework in Frameworks */,
|
||||
098FBDD615D704E800623941 /* Foundation.framework in Frameworks */,
|
||||
098FBDD815D704E800623941 /* CoreGraphics.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
098FBDC415D704E800623941 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
099C7342169016D800239880 /* Default-568h@2x.png */,
|
||||
098FBDD915D704E800623941 /* OHHTTPStubsDemo */,
|
||||
098FBDD215D704E800623941 /* Frameworks */,
|
||||
098FBDD015D704E800623941 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
098FBDD015D704E800623941 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
098FBDCF15D704E800623941 /* OHHTTPStubsDemo.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
098FBDD215D704E800623941 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
098FBDD315D704E800623941 /* UIKit.framework */,
|
||||
098FBDD515D704E800623941 /* Foundation.framework */,
|
||||
098FBDD715D704E800623941 /* CoreGraphics.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
098FBDD915D704E800623941 /* OHHTTPStubsDemo */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
098FBDEA15D7056200623941 /* MainViewController.h */,
|
||||
098FBDEB15D7056200623941 /* MainViewController.m */,
|
||||
098FBDEC15D7056200623941 /* MainViewController.xib */,
|
||||
098FBDFA15D70E2F00623941 /* Stubs */,
|
||||
098FBDDA15D704E800623941 /* Supporting Files */,
|
||||
);
|
||||
name = OHHTTPStubsDemo;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
098FBDDA15D704E800623941 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
098FBDDB15D704E800623941 /* OHHTTPStubsDemo-Info.plist */,
|
||||
098FBDDF15D704E800623941 /* main.m */,
|
||||
098FBDE115D704E800623941 /* OHHTTPStubsDemo-Prefix.pch */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
098FBDFA15D70E2F00623941 /* Stubs */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
097935A1161B654E006DB5D5 /* libOHHTTPStubs.a */,
|
||||
098FBDF615D70E2600623941 /* stub.jpg */,
|
||||
098FBDF715D70E2600623941 /* stub.txt */,
|
||||
);
|
||||
name = Stubs;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
098FBDCE15D704E800623941 /* OHHTTPStubsDemo */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 098FBDE715D704E800623941 /* Build configuration list for PBXNativeTarget "OHHTTPStubsDemo" */;
|
||||
buildPhases = (
|
||||
098FBDCB15D704E800623941 /* Sources */,
|
||||
098FBDCC15D704E800623941 /* Frameworks */,
|
||||
098FBDCD15D704E800623941 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = OHHTTPStubsDemo;
|
||||
productName = OHHTTPStubsDemo;
|
||||
productReference = 098FBDCF15D704E800623941 /* OHHTTPStubsDemo.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
098FBDC615D704E800623941 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0440;
|
||||
ORGANIZATIONNAME = AliSoftware;
|
||||
};
|
||||
buildConfigurationList = 098FBDC915D704E800623941 /* Build configuration list for PBXProject "OHHTTPStubsDemo" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 098FBDC415D704E800623941;
|
||||
productRefGroup = 098FBDD015D704E800623941 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
098FBDCE15D704E800623941 /* OHHTTPStubsDemo */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
098FBDCD15D704E800623941 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
098FBDEE15D7056200623941 /* MainViewController.xib in Resources */,
|
||||
098FBDF815D70E2600623941 /* stub.jpg in Resources */,
|
||||
098FBDF915D70E2600623941 /* stub.txt in Resources */,
|
||||
099C7343169016D800239880 /* Default-568h@2x.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
098FBDCB15D704E800623941 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
098FBDE015D704E800623941 /* main.m in Sources */,
|
||||
098FBDED15D7056200623941 /* MainViewController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
098FBDE515D704E800623941 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
098FBDE615D704E800623941 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
098FBDE815D704E800623941 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "OHHTTPStubsDemo-Prefix.pch";
|
||||
INFOPLIST_FILE = "OHHTTPStubsDemo-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
098FBDE915D704E800623941 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "OHHTTPStubsDemo-Prefix.pch";
|
||||
INFOPLIST_FILE = "OHHTTPStubsDemo-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
098FBDC915D704E800623941 /* Build configuration list for PBXProject "OHHTTPStubsDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
098FBDE515D704E800623941 /* Debug */,
|
||||
098FBDE615D704E800623941 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
098FBDE715D704E800623941 /* Build configuration list for PBXNativeTarget "OHHTTPStubsDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
098FBDE815D704E800623941 /* Debug */,
|
||||
098FBDE915D704E800623941 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 098FBDC615D704E800623941 /* Project object */;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0450"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "NO"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "098FBDCE15D704E800623941"
|
||||
BuildableName = "OHHTTPStubsDemo.app"
|
||||
BlueprintName = "OHHTTPStubsDemo"
|
||||
ReferencedContainer = "container:OHHTTPStubsDemo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "098368CD168FC7920082B1A4"
|
||||
BuildableName = "UnitTests.octest"
|
||||
BlueprintName = "UnitTests"
|
||||
ReferencedContainer = "container:../OHHTTPStubs/OHHTTPStubs.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "AsyncSenTestCase">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "098FBDCE15D704E800623941"
|
||||
BuildableName = "OHHTTPStubsDemo.app"
|
||||
BlueprintName = "OHHTTPStubsDemo"
|
||||
ReferencedContainer = "container:OHHTTPStubsDemo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "098FBDCE15D704E800623941"
|
||||
BuildableName = "OHHTTPStubsDemo.app"
|
||||
BlueprintName = "OHHTTPStubsDemo"
|
||||
ReferencedContainer = "container:OHHTTPStubsDemo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "098FBDCE15D704E800623941"
|
||||
BuildableName = "OHHTTPStubsDemo.app"
|
||||
BlueprintName = "OHHTTPStubsDemo"
|
||||
ReferencedContainer = "container:OHHTTPStubsDemo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// main.m
|
||||
// OHHTTPStubsDemo
|
||||
//
|
||||
// Created by Olivier Halligon on 11/08/12.
|
||||
// Copyright (c) 2012 AliSoftware. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, nil);
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 46 KiB |
@@ -0,0 +1 @@
|
||||
This is the text from your stub.
|
||||
@@ -0,0 +1,277 @@
|
||||
OHHTTPStubs
|
||||
===========
|
||||
|
||||
A class to stub network requests easily: test your apps with fake network data (stubbed from file) and custom response time
|
||||
|
||||
* [Basic Usage](#basic-usage)
|
||||
* [The `OHHTTPStubsResponse` object](#the-ohhttpstubsresponse-object)
|
||||
* [Advanced Usage](#advanced-usage)
|
||||
* [Return a response depending on the request](#return-a-response-depending-on-the-request)
|
||||
* [Using download speed instead of responseTime](#using-download-speed-instead-of-responsetime)
|
||||
* [Return quickly when `onlyCheck=YES`](#return-quickly-when-onlycheckyes)
|
||||
* [Stack multiple requestHandlers](#stack-multiple-requesthandlers)
|
||||
* [Complete Examples](#complete-examples)
|
||||
* [Installing in your projects](#installing-in-your-projects)
|
||||
* [About OHHTTPStubs Unit Tests](#about-ohhttpstubs-unit-tests)
|
||||
* [Change Log](#change-log)
|
||||
* [License and Credits](#license-and-credits)
|
||||
|
||||
----
|
||||
|
||||
## Basic Usage
|
||||
|
||||
This is aimed to be very simple to use. It uses block to intercept outgoing requests and allow you to
|
||||
return data from a file instead.
|
||||
|
||||
##### This is the most simple way to use it:
|
||||
|
||||
[OHHTTPStubs addRequestHandler:^OHHTTPStubsResponse*(NSURLRequest *request, BOOL onlyCheck) {
|
||||
return [OHHTTPStubsResponse responseWithFile:@"response.json" contentType:@"text/json" responseTime:2.0];
|
||||
}];
|
||||
|
||||
This will return the `NSData` corresponding to the content of the `"response.json"` file (that must be in your bundle)
|
||||
with a `"Content-Type"` header of `"text/json"` in the HTTP response, after 2 seconds.
|
||||
|
||||
##### We can also conditionally stub only certain requests, like this:
|
||||
|
||||
[OHHTTPStubs shouldStubRequestsPassingTest:^BOOL(NSURLRequest *request) {
|
||||
// Only stub requests to "*.json" files
|
||||
return [request.URL.absoluteString.lastPathComponent.pathExtension isEqualToString:@"json"];
|
||||
} withStubResponse:^OHHTTPStubsResponse*(NSURLRequest *request) {
|
||||
// Stub it with our "response.json" stub file
|
||||
return [OHHTTPStubsResponse responseWithFile:@"response.json" contentType:@"text/json" responseTime:2.0];
|
||||
}];
|
||||
|
||||
##### Then each time a network request is done by your application
|
||||
|
||||
For every request sent, whatever the framework used (`NSURLConnection`,
|
||||
[`AFNetworking`](https://github.com/AFNetworking/AFNetworking/), or anything else):
|
||||
|
||||
* If you used `shouldStubRequestsPassingTest:withStubResponse:`
|
||||
* The block passed as first argument will be called to check if we need to stub this request.
|
||||
* If this block returned YES, the block passed as second argument will be called to let you return an `OHHTTPStubsResponse` object, describing the fake response to return.
|
||||
* If you used `addRequestHandler:`
|
||||
* If you return a non-nil `OHHTTPStubsResponse`, the request will be stubbed by returning the corresponding fake response.
|
||||
* If your return `nil`, the normal request will be sent (no stubbing).
|
||||
|
||||
_(See also "[Return quickly when `onlyCheck=YES`](#return-quickly-when-onlycheckyes)" below)_
|
||||
|
||||
|
||||
## The `OHHTTPStubsResponse` object
|
||||
|
||||
The `OHHTTPStubsResponse` class, describing the fake response to return, exposes multiple initializers:
|
||||
|
||||
##### The designed intializer
|
||||
+(id)responseWithData:(NSData*)data
|
||||
statusCode:(int)statusCode
|
||||
responseTime:(NSTimeInterval)responseTime
|
||||
headers:(NSDictionary*)httpHeaders;
|
||||
|
||||
##### Commodity initializer to load data from a file in your bundle
|
||||
+(id)responseWithFile:(NSString*)fileName
|
||||
statusCode:(int)statusCode
|
||||
responseTime:(NSTimeInterval)responseTime
|
||||
headers:(NSDictionary*)httpHeaders;
|
||||
|
||||
##### Useful short-form initializer to load data from a file in your bundle, using the specified "Content-Type" header
|
||||
+(id)responseWithFile:(NSString*)fileName
|
||||
contentType:(NSString*)contentType
|
||||
responseTime:(NSTimeInterval)responseTime;
|
||||
|
||||
##### To respond with an error instead of a success
|
||||
+(id)responseWithError:(NSError*)error;
|
||||
_(e.g. you could use an error like `[NSError errorWithDomain:NSURLErrorDomain code:404 userInfo:nil]`)_
|
||||
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Return a response depending on the request
|
||||
|
||||
Of course, and that's the main reason this is implemented with blocks,
|
||||
you can do whatever you need in the block implementation. This includes
|
||||
checking the request URL to see if you want to return a stub or not,
|
||||
and pick the right file according to the requested URL.
|
||||
|
||||
You can use either `addRequestHandler:` or `shouldStubRequestsPassingTest:withStubResponse:` to install a stubbed request.
|
||||
[See below](#return-quickly-when-onlycheckyes).
|
||||
|
||||
Example:
|
||||
|
||||
[OHHTTPStubs addRequestHandler:^OHHTTPStubsResponse*(NSURLRequest *request, BOOL onlyCheck)
|
||||
{
|
||||
NSString* basename = request.URL.absoluteString.lastPathComponent;
|
||||
if ([basename.pathExtension isEqualToString:@"json"]) {
|
||||
return [OHHTTPStubsResponse responseWithFile:basename contentType:@"text/json" responseTime:2.0];
|
||||
} else {
|
||||
return nil; // Don't stub
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
### Using download speed instead of responseTime
|
||||
|
||||
When building the `OHHTTPStubsResponse` object, you can specify a response time (in seconds) so
|
||||
that the sending of the fake response will be postponed. This allows you to simulate a slow network for example.
|
||||
|
||||
If you specify a negative value for the responseTime parameter, instead of being interpreted as
|
||||
a time in seconds, it will be interpreted as a download speed in KBytes/s.
|
||||
In that case, the response time will be computed using the size of the response's data to simulate
|
||||
the indicated download speed.
|
||||
|
||||
The `OHHTTPStubsResponse` header defines some constants for standard download speeds:
|
||||
* `OHHTTPStubsDownloadSpeedGPRS` : 56 kbps (7 KB/s)
|
||||
* `OHHTTPStubsDownloadSpeedEDGE` : 128 kbps (16 KB/s)
|
||||
* `OHHTTPStubsDownloadSpeed3G` : 3200 kbps (400 KB/s)
|
||||
* `OHHTTPStubsDownloadSpeed3GPlus` : 7200 kbps (900 KB/s)
|
||||
* `OHHTTPStubsDownloadSpeedWifi` : 12000 kbps (1500 KB/s)
|
||||
|
||||
### Return quickly when `onlyCheck=YES`
|
||||
|
||||
When using `addRequestHandler:`, if the `onlyCheck` parameter of the requestHandler block is `YES`, then it means that the handler is called
|
||||
only to check if you will be able to return a stubbed response or if it has to do the standard request.
|
||||
In this scenario, the response will not actually be used but will only be compared to `nil` to check if it has to be stubbed later.
|
||||
_The handler will be called later again (with `onlyCheck=NO`) to fetch the actual `OHHTTPStubsResponse` object._
|
||||
|
||||
So in such cases (`onlyCheck==YES`), you can simply return `nil` if you don't want to provide a stubbed response,
|
||||
and **_any_ non-nil value** to indicate that you will provide a stubbed response later.
|
||||
|
||||
This may be useful if you intend to do some not-so-fast work to build your real `OHHTTPStubsResponse`
|
||||
(like reading some large file for example): in that case you can quickly return a dummy value when `onlyCheck==YES`
|
||||
without the burden of building the actual `OHHTTPStubsResponse` object.
|
||||
You will obviously return the real `OHHTTPStubsResponse` in the later call when `onlyCheck==NO`.
|
||||
|
||||
_There is a macro `OHHTTPStubsResponseUseStub` provided in the header that you can use as a dummy return value for that purpose._
|
||||
|
||||
---
|
||||
|
||||
To avoid forgetting about quickly return if the handler is called only for checking the availability of a stub, you may
|
||||
prefer using the `shouldStubRequestsPassingTest:withStubResponse:` class method, which uses two distinct blocks: one to
|
||||
only quickly check that the request should be stubbed, and the other to build and return the actual stubbed response.
|
||||
|
||||
Example:
|
||||
|
||||
[OHHTTPStubs shouldStubRequestPassingTest:^BOOL(NSURLRequest *request) {
|
||||
NSString* basename = request.URL.absoluteString.lastPathComponent;
|
||||
return [basename.pathExtension isEqualToString:@"json"]; // only stub requests for "*.json" files
|
||||
} withStubResponse:^OHHTTPStubsResponse* (NSURLRequest* request))handler {
|
||||
// This block will only be called if the previous one has returned YES (so only for "*.json" files)
|
||||
NSString* basename = request.URL.absoluteString.lastPathComponent;
|
||||
return [OHHTTPStubsResponse responseWithFile:basename contentType:@"text/json" responseTime:2.0];
|
||||
}];
|
||||
|
||||
> Note: in practice, this method calls `addResponseHandler:`, and pass it a new block that:
|
||||
> * calls the first block to check if we need to stub, and
|
||||
> * directly return `OHHTTPStubsResponseUseStub` or `OHHTTPStubsResponseDontUseStub` if `onlyCheck=YES`
|
||||
> * or call the second block to return the actual stub only if `onlyCheck=NO`.
|
||||
|
||||
_Note that even if you want to stub all your requests unconditionally, it is still better to
|
||||
use `shouldStubRequestsPassingTest:withStubResponse:` with the first block always returning `YES`,
|
||||
because it will prevent building the whole stubbed response multiple times (once or more when only checking,
|
||||
and one final time when actually returning it)._
|
||||
|
||||
|
||||
### Stack multiple requestHandlers
|
||||
|
||||
You can call `addRequestHandler:` or `shouldStubRequestsPassingTest:withStubResponse:` multiple times.
|
||||
It will just add the response handlers in an internal list of handlers.
|
||||
|
||||
When a network request is performed by the system, the response handlers are called in the reverse
|
||||
order that they have been added, the last added handler having priority over the first added ones.
|
||||
The first handler that returns a stub (non-nil response for `addRequestHandler:`,
|
||||
or first block returning YES for `shouldStubRequestsPassingTest:withStubResponse:`) is then used to reply to the request.
|
||||
|
||||
_This may be useful to install different stubs in different classes (say different UIViewControllers)
|
||||
and various places in your application, or to separate different stubs and stubbing conditions
|
||||
(like some stubs for images and other stubs for JSON files) more easily.
|
||||
See the `OHHTTPStubsDemo` project for a typical example._
|
||||
|
||||
You can remove the latest added handler with the `removeLastRequestHandler` method.
|
||||
|
||||
You can also remove any given handler with the `removeRequestHandler:` method.
|
||||
This method takes as a parameter the object returned by `addRequestHandler:` or `shouldStubRequestsPassingTest:withStubResponse:`.
|
||||
_Note that this returned object is already retained by `OHHTTPStubs` while the stub is installed,
|
||||
so you may keep it in a `__weak` variable (no need to keep a `__strong` reference)._
|
||||
|
||||
|
||||
|
||||
## Complete examples
|
||||
|
||||
Here is another example code below that uses the various techniques explained above.
|
||||
For a complete Xcode projet, see the `OHHTTPStubsDemo.xcworkspace` project in the repository.
|
||||
|
||||
|
||||
NSArray* stubs = [NSArray arrayWithObjects:@"file1", @"file2", nil];
|
||||
|
||||
[OHHTTPStubs shouldStubRequestPassingTest:^OHHTTPStubsResponse*(NSURLRequest *request) {
|
||||
return [stubs containsObject:request.URL.absoluteString.lastPathComponent];
|
||||
} withStubResponse:^OHHTTPStubsResponse* (NSURLRequest* request))handler {
|
||||
NSString* file = [request.URL.absoluteString.lastPathComponent
|
||||
stringByAppendingPathExtension:@"json"];
|
||||
return [OHHTTPStubsResponse responseWithFile:file contentType:@"text/json"
|
||||
responseTime:OHHTTPStubsDownloadSpeedEDGE];
|
||||
}];
|
||||
|
||||
...
|
||||
|
||||
// Then this call (sending a request using the AFNetworking framework) will actually
|
||||
// receive a fake response issued from the file "file1.json"
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.example.com/file1"]];
|
||||
[[AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON)
|
||||
{
|
||||
...
|
||||
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON)
|
||||
{
|
||||
...
|
||||
}] start];
|
||||
|
||||
|
||||
|
||||
## Installing in your projects
|
||||
|
||||
The `OHHTTPStubs` project is provided as a Xcode project that generates a static library, to easily integrate it with your project.
|
||||
|
||||
1. Add the `OHHTTPStubs.xcodeproj` project to your application workspace, next to your application project
|
||||
2. Link `libOHHTTPStubs.a` with your application project:
|
||||
* Select your application project in the Project Navigator, then select your target in which you want to use `OHHTTPStubs`
|
||||
(for example **your Tests target** if you will only use `OHHTTPStubs` in your Unit Tests)
|
||||
* Go to the "Build Phase" tab and open the "Link Binary With Libraries" phase
|
||||
* Use the "+" button to add the `libOHHTTPStubs.a` library to the libraries linked with your project
|
||||
3. When you need to use `OHHTTPStubs` classes, import the headers using square brackets: `#import <OHHTTPStubs/OHHTTPStubs.h>`
|
||||
|
||||
_Note: due to a bug in Xcode4, you will have to ensure that the `libOHHTTPStubs.a` file reference added in your project
|
||||
has its path referenced as "Relative to Build Products" as it should.
|
||||
If it is not the case, please read the [detailed instructions here](http://github.com/AliSoftware/OHHTTPStubs/wiki/Detailed-Integration-Instruction)._
|
||||
|
||||
> ### **Important Note**
|
||||
`OHHTTPStubs` is designed to be used **in test/debug code only**.
|
||||
**Don't link with it in production code when you compile your final application for the AppStore**.
|
||||
|
||||
> _Its code use a private API to build an `NSHTTPURLResponse`, which is not authorized by Apple in applications published on the AppStore.
|
||||
So you will probably only link it with your Unit Tests target, or inside some `#if DEBUG`/`#endif` portions of your code._
|
||||
|
||||
## About `OHHTTPStubs` Unit Tests
|
||||
|
||||
`OHHTTPStubs` include some *Unit Tests*, and some of them test cases when using `OHHTTPStubs` with the [`AFNetworking`](https://github.com/AFNetworking/AFNetworking/) framework.
|
||||
To implement those test cases, `AFNetworking` has been added as a _GIT submodule_ inside the "Unit Tests" folder.
|
||||
This means that if you want to be able to run `OHHTTPStubs`' Unit Tests,
|
||||
you need to include submodules when cloning, by using the `--recursive` option:
|
||||
`git clone --recursive <this_repo_url> <destination_folder>`.
|
||||
Alternatively if you didn't include the `--recursive` flag when cloning, you can use `git submodule init` and then `git submodule update`
|
||||
on your already cloned working copy to initialize and fetch/update the submodules.
|
||||
|
||||
_This is only needed if you intend to run the `OHHTTPStubs` Unit Tests, to check the correct behavior of `OHHTTPStubs`
|
||||
in conjunction with `AFNetworking`. If you only intend to directly use the `OHHTTPStubs`'s
|
||||
produced library and will never run the `OHHTTPStubs` Unit Tests, the `AFNetworking` submodule is not needed at all._
|
||||
|
||||
## Change Log
|
||||
|
||||
The changelog is available [here in the dedicated wiki page](https://github.com/AliSoftware/OHHTTPStubs/wiki/ChangeLog).
|
||||
|
||||
|
||||
## License and Credits
|
||||
|
||||
This project is brought to you by Olivier Halligon and is under MIT License
|
||||
|
||||
It has been inspired by [this article from InfiniteLoop.dk](http://www.infinite-loop.dk/blog/2011/09/using-nsurlprotocol-for-injecting-test-data/)
|
||||
_(See also his [GitHub repository](https://github.com/InfiniteLoopDK/ILTesting))_
|
||||
|
||||