Clean up inconsistencies with 'cancelled' and 'cancel' to match Cocoa (isCancelled)

This commit is contained in:
Blake Watters
2012-05-21 18:09:08 -04:00
parent 871ab1389e
commit 9ca2ba2a3f
4 changed files with 15 additions and 13 deletions

View File

@@ -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 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
@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 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
_connection = nil;
self.loading = NO;
self.loaded = NO;
self.canceled = NO;
self.cancelled = NO;
}
- (void)cleanupBackgroundTask {
@@ -407,7 +406,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
}
- (void)cancelAndInformDelegate:(BOOL)informDelegate {
_cancelled = YES;
self.cancelled = YES;
[_connection cancel];
[_connection release];
_connection = nil;
@@ -436,7 +435,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
- (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 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
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 File

@@ -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 File

@@ -389,7 +389,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
- (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 @@ static const NSTimeInterval kFlushDelay = 0.3;
[_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 File

@@ -123,7 +123,7 @@
- (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 @@
object:self
userInfo:userInfo];
}
[self informDelegateOfError:error];
if (! self.isCancelled) {
[self informDelegateOfError:error];
}
[self finalizeLoad:NO];
}