mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
Clean up inconsistencies with 'cancelled' and 'cancel' to match Cocoa (isCancelled)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user