Refactored object manager API's to de-emphasize delegates and removal duplication of blocks and delegates. Added block callbacks to RKObjectLoader.

This commit is contained in:
Blake Watters
2012-01-19 09:09:56 -05:00
parent 4bd12ea987
commit 1d27f7bbbe
12 changed files with 592 additions and 367 deletions

View File

@@ -64,6 +64,8 @@
@synthesize timeoutInterval = _timeoutInterval;
@synthesize reachabilityObserver = _reachabilityObserver;
@synthesize configurationDelegate = _configurationDelegate;
@synthesize onDidLoadResponse;
@synthesize onDidFailLoadWithError;
#if TARGET_OS_IPHONE
@synthesize backgroundPolicy = _backgroundPolicy, backgroundTaskIdentifier = _backgroundTaskIdentifier;
@@ -167,6 +169,10 @@
_OAuth2AccessToken = nil;
[_OAuth2RefreshToken release];
_OAuth2RefreshToken = nil;
[onDidFailLoadWithError release];
onDidFailLoadWithError = nil;
[onDidLoadResponse release];
onDidLoadResponse = nil;
[self invalidateTimeoutTimer];
[_timeoutTimer release];
_timeoutTimer = nil;
@@ -565,6 +571,10 @@
[_delegate request:self didFailLoadWithError:error];
}
if (self.onDidFailLoadWithError) {
self.onDidFailLoadWithError(error);
}
NSDictionary* userInfo = [NSDictionary dictionaryWithObject:error forKey:RKRequestDidFailWithErrorNotificationUserInfoErrorKey];
[[NSNotificationCenter defaultCenter] postNotificationName:RKRequestDidFailWithErrorNotification
object:self
@@ -600,6 +610,10 @@
[_delegate request:self didLoadResponse:finalResponse];
}
if (self.onDidLoadResponse) {
self.onDidLoadResponse(finalResponse);
}
if ([response isServiceUnavailable]) {
[[NSNotificationCenter defaultCenter] postNotificationName:RKServiceDidBecomeUnavailableNotification object:self];
}