Skip to content
Browse files

Clean up inconsistencies with 'cancelled' and 'cancel' to match Cocoa…

… (isCancelled)
  • Loading branch information...
1 parent 871ab13 commit 9ca2ba2a3fe601e82745f5695cb5b9d000e11572 @blakewatters blakewatters committed May 21, 2012
View
13 Code/Network/RKRequest.m
@@ -88,7 +88,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
@interface RKRequest ()
@property (nonatomic, assign, readwrite, getter = isLoaded) BOOL loaded;
@property (nonatomic, assign, readwrite, getter = isLoading) BOOL loading;
-@property (nonatomic, assign, readwrite) BOOL canceled;
+@property (nonatomic, assign, readwrite, getter = isCancelled) BOOL cancelled;
@property (nonatomic, retain, readwrite) RKResponse *response;
@end
@@ -123,13 +123,12 @@ @implementation RKRequest
@synthesize onDidFailLoadWithError;
@synthesize additionalRootCertificates = _additionalRootCertificates;
@synthesize disableCertificateValidation = _disableCertificateValidation;
-@synthesize cancelled = _cancelled;
@synthesize followRedirect = _followRedirect;
@synthesize runLoopMode = _runLoopMode;
@synthesize loaded = _loaded;
@synthesize loading = _loading;
-@synthesize canceled = _canceled;
@synthesize response = _response;
+@synthesize cancelled = _cancelled;
#if TARGET_OS_IPHONE
@synthesize backgroundPolicy = _backgroundPolicy;
@@ -184,7 +183,7 @@ - (void)reset {
_connection = nil;
self.loading = NO;
self.loaded = NO;
- self.canceled = NO;
+ self.cancelled = NO;
}
- (void)cleanupBackgroundTask {
@@ -407,7 +406,7 @@ - (BOOL)prepareURLRequest {
}
- (void)cancelAndInformDelegate:(BOOL)informDelegate {
- _cancelled = YES;
+ self.cancelled = YES;
[_connection cancel];
[_connection release];
_connection = nil;
@@ -436,7 +435,7 @@ - (void)send {
- (void)fireAsynchronousRequest {
RKLogDebug(@"Sending asynchronous %@ request to URL %@.", [self HTTPMethod], [[self URL] absoluteString]);
if (![self prepareURLRequest]) {
- // TODO: Logging
+ RKLogWarning(@"Failed to send request asynchronously: prepareURLRequest returned NO.");
return;
}
@@ -565,7 +564,7 @@ - (RKResponse*)sendSynchronously {
RKLogDebug(@"Sending synchronous %@ request to URL %@.", [self HTTPMethod], [[self URL] absoluteString]);
if (![self prepareURLRequest]) {
- // TODO: Logging
+ RKLogWarning(@"Failed to send request synchronously: prepareURLRequest returned NO.");
return nil;
}
View
4 Code/Network/RKRequestQueue.h
@@ -159,7 +159,7 @@
reference and canceling the request.
Useful when an object that acts as the delegate for one or more requests
- is being deallocated and all outstanding requests should be canceled
+ is being deallocated and all outstanding requests should be cancelled
without generating any further delegate callbacks.
@param delegate The object acting as the delegate for all enqueued requests that are to be aborted.
@@ -314,7 +314,7 @@
- (void)requestQueue:(RKRequestQueue *)queue didLoadResponse:(RKResponse *)response;
/**
- Sent when queue has canceled a request.
+ Sent when queue has cancelled a request.
@param queue The queue that cancelled the request.
@param request The cancelled request.
View
4 Code/Network/RKRequestQueue.m
@@ -389,7 +389,7 @@ - (BOOL)containsRequest:(RKRequest*)request {
- (void)cancelRequest:(RKRequest*)request loadNext:(BOOL)loadNext {
if ([request isUnsent]) {
- RKLogDebug(@"Canceled undispatched request %@ and removed from queue %@", request, self);
+ RKLogDebug(@"Cancelled undispatched request %@ and removed from queue %@", request, self);
[self removeRequest:request];
request.delegate = nil;
@@ -398,7 +398,7 @@ - (void)cancelRequest:(RKRequest*)request loadNext:(BOOL)loadNext {
[_delegate requestQueue:self didCancelRequest:request];
}
} else if ([self containsRequest:request] && [request isLoading]) {
- RKLogDebug(@"Canceled loading request %@ and removed from queue %@", request, self);
+ RKLogDebug(@"Cancelled loading request %@ and removed from queue %@", request, self);
[request cancel];
request.delegate = nil;
View
7 Code/ObjectMapping/RKObjectLoader.m
@@ -123,7 +123,7 @@ - (void)informDelegateOfError:(NSError *)error {
- (void)finalizeLoad:(BOOL)successful {
self.loading = NO;
self.loaded = successful;
-
+
if ([self.delegate respondsToSelector:@selector(objectLoaderDidFinishLoading:)]) {
[(NSObject<RKObjectLoaderDelegate>*)self.delegate performSelectorOnMainThread:@selector(objectLoaderDidFinishLoading:)
withObject:self waitUntilDone:YES];
@@ -407,7 +407,10 @@ - (void)didFailLoadWithError:(NSError *)error {
object:self
userInfo:userInfo];
}
- [self informDelegateOfError:error];
+
+ if (! self.isCancelled) {
+ [self informDelegateOfError:error];
+ }
[self finalizeLoad:NO];
}

0 comments on commit 9ca2ba2

Please sign in to comment.
Something went wrong with that request. Please try again.