diff --git a/Snapper.xcworkspace/xcuserdata/pauly.xcuserdatad/UserInterfaceState.xcuserstate b/Snapper.xcworkspace/xcuserdata/pauly.xcuserdatad/UserInterfaceState.xcuserstate index 394b28b..a45888a 100644 Binary files a/Snapper.xcworkspace/xcuserdata/pauly.xcuserdatad/UserInterfaceState.xcuserstate and b/Snapper.xcworkspace/xcuserdata/pauly.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Snapper/Source/Shared/SNPBaseClientOperation.h b/Snapper/Source/Shared/SNPBaseClientOperation.h index 84f75f1..40594f8 100644 --- a/Snapper/Source/Shared/SNPBaseClientOperation.h +++ b/Snapper/Source/Shared/SNPBaseClientOperation.h @@ -39,6 +39,7 @@ @property (nonatomic, copy) id (^serializationBlock)(id data, NSError** error); @property (nonatomic, assign) Class serializationRootClass; @property (nonatomic, assign) Class serializationArrayClass; +@property (nonatomic, assign) NSTimeInterval timeout; // -- Initializers -- diff --git a/Snapper/Source/Shared/SNPBaseClientOperation.m b/Snapper/Source/Shared/SNPBaseClientOperation.m index 1043e44..46fc2e6 100644 --- a/Snapper/Source/Shared/SNPBaseClientOperation.m +++ b/Snapper/Source/Shared/SNPBaseClientOperation.m @@ -58,13 +58,13 @@ - (instancetype)initWithFinishBlock:(void (^)(SNPResponse* response))finishBlock } - (instancetype)initWithEndpoint:(NSURL*)endpoint - method:(NSString*)method - headers:(NSDictionary*)headers - parameters:(NSDictionary*)parameters - body:(NSData*)body - bodyType:(NSString*)bodyType - progressBlock:(void (^)(NSUInteger bytesWritten, NSUInteger totalBytesWritten, NSUInteger totalBytes))progressBlock - finishBlock:(void (^)(SNPResponse* response))finishBlock { + method:(NSString*)method + headers:(NSDictionary*)headers + parameters:(NSDictionary*)parameters + body:(NSData*)body + bodyType:(NSString*)bodyType + progressBlock:(void (^)(NSUInteger bytesWritten, NSUInteger totalBytesWritten, NSUInteger totalBytes))progressBlock + finishBlock:(void (^)(SNPResponse* response))finishBlock { self = [self initWithFinishBlock:finishBlock]; if(self) { @@ -106,7 +106,9 @@ - (void)main { _endpoint = [NSURL URLWithString:urlString]; } - NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:_endpoint]; + NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:_endpoint + cachePolicy:NSURLRequestReloadIgnoringLocalCacheData + timeoutInterval:_timeout ?: 10]; // Provided headers [_headers enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL* stop) { @@ -359,7 +361,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection*)connection { NSAssert(YES, @"Cannot deserialize response data; no deserialization method is set for this operation!"); } } - + if(_finishBlock) { _finishBlock(response); } diff --git a/Snapper/Source/Shared/SNPBaseFileOperation.h b/Snapper/Source/Shared/SNPBaseFileOperation.h index 6a5726d..5f0f8ac 100644 --- a/Snapper/Source/Shared/SNPBaseFileOperation.h +++ b/Snapper/Source/Shared/SNPBaseFileOperation.h @@ -29,6 +29,7 @@ @property (nonatomic, copy) id (^serializationBlock)(id data, NSError** error); @property (nonatomic, assign) Class serializationRootClass; @property (nonatomic, assign) Class serializationArrayClass; +@property (nonatomic, assign) NSTimeInterval timeout; // -- Initializers -- - (instancetype)initWithAccountId:(NSString*)accountId diff --git a/Snapper/Source/Shared/SNPBaseFileOperation.m b/Snapper/Source/Shared/SNPBaseFileOperation.m index e99ea49..3140ed0 100644 --- a/Snapper/Source/Shared/SNPBaseFileOperation.m +++ b/Snapper/Source/Shared/SNPBaseFileOperation.m @@ -128,7 +128,9 @@ - (void)main { _endpoint = [NSURL URLWithString:urlString]; } - NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:_endpoint]; + NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:_endpoint + cachePolicy:NSURLRequestReloadIgnoringLocalCacheData + timeoutInterval:_timeout ?: 10]; // Provided headers [_headers enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL* stop) { @@ -334,7 +336,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection*)connection { response.data = arrayOfData; } } - + if(_finishBlock) { _finishBlock(response); } diff --git a/Snapper/Source/Shared/SNPBaseImageFetchOperation.h b/Snapper/Source/Shared/SNPBaseImageFetchOperation.h index 7d60447..bc2b964 100644 --- a/Snapper/Source/Shared/SNPBaseImageFetchOperation.h +++ b/Snapper/Source/Shared/SNPBaseImageFetchOperation.h @@ -15,6 +15,7 @@ // -- Properties -- @property (nonatomic, retain) NSURL* imageURL; @property (nonatomic, copy) void (^finishBlock)(id image, NSError* error); +@property (nonatomic, assign) NSTimeInterval timeout; // -- Initializers -- - (instancetype)initWithImageURL:(NSURL*)imageURL diff --git a/Snapper/Source/Shared/SNPBaseImageFetchOperation.m b/Snapper/Source/Shared/SNPBaseImageFetchOperation.m index 049b2a2..0c82e5c 100644 --- a/Snapper/Source/Shared/SNPBaseImageFetchOperation.m +++ b/Snapper/Source/Shared/SNPBaseImageFetchOperation.m @@ -45,7 +45,9 @@ - (void)main { _receivedData = [NSMutableData new]; - NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:_imageURL]; + NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:_imageURL + cachePolicy:NSURLRequestReloadIgnoringLocalCacheData + timeoutInterval:_timeout ?: 10]; [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; diff --git a/Snapper/Source/Shared/SNPBaseUserTokenOperation.m b/Snapper/Source/Shared/SNPBaseUserTokenOperation.m index b33ca21..026f914 100755 --- a/Snapper/Source/Shared/SNPBaseUserTokenOperation.m +++ b/Snapper/Source/Shared/SNPBaseUserTokenOperation.m @@ -115,7 +115,9 @@ - (void)main { self.endpoint = [NSURL URLWithString:urlString]; } - NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:self.endpoint]; + NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:self.endpoint + cachePolicy:NSURLRequestReloadIgnoringLocalCacheData + timeoutInterval:self.timeout ?: 10]; // Provided headers [self.headers enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL* stop) {