Update RKObjectManager to observe changes to the reachability observer of

the underlying RKClient object. refs #717
This commit is contained in:
Boris Dušek
2012-05-06 17:21:22 +02:00
committed by Blake Watters
parent 5387f0b262
commit e932c31cde
7 changed files with 109 additions and 30 deletions

View File

@@ -209,7 +209,7 @@
/**
A dictionary of headers to be sent with each request
*/
@property (nonatomic, readonly) NSMutableDictionary *HTTPHeaders;
@property (nonatomic, retain, readonly) NSMutableDictionary *HTTPHeaders;
/**
An optional timeout interval within which the request should be cancelled.
@@ -271,7 +271,7 @@
A set of additional certificates to be used in evaluating server SSL
certificates.
*/
@property (nonatomic, readonly) NSSet *additionalRootCertificates;
@property (nonatomic, retain, readonly) NSSet *additionalRootCertificates;
/**
Adds an additional certificate that will be used to evaluate server SSL certs.

View File

@@ -65,6 +65,11 @@ NSString *RKPathAppendQueryParams(NSString *resourcePath, NSDictionary *queryPar
///////////////////////////////////////////////////////////////////////////////////////////////////
@interface RKClient ()
@property (nonatomic, retain, readwrite) NSMutableDictionary *HTTPHeaders;
@property (nonatomic, retain, readwrite) NSSet *additionalRootCertificates;
@end
@implementation RKClient
@synthesize baseURL = _baseURL;
@@ -121,25 +126,24 @@ NSString *RKPathAppendQueryParams(NSString *resourcePath, NSDictionary *queryPar
- (id)init {
self = [super init];
if (self) {
_HTTPHeaders = [[NSMutableDictionary alloc] init];
_additionalRootCertificates = [[NSMutableSet alloc] init];
_defaultHTTPEncoding = NSUTF8StringEncoding;
self.HTTPHeaders = [[NSMutableDictionary alloc] init];
self.additionalRootCertificates = [[NSMutableSet alloc] init];
self.defaultHTTPEncoding = NSUTF8StringEncoding;
self.cacheTimeoutInterval = 0;
self.runLoopMode = NSRunLoopCommonModes;
self.serviceUnavailableAlertEnabled = NO;
self.serviceUnavailableAlertTitle = NSLocalizedString(@"Service Unavailable", nil);
self.serviceUnavailableAlertMessage = NSLocalizedString(@"The remote resource is unavailable. Please try again later.", nil);
self.requestQueue = [RKRequestQueue requestQueue];
self.serviceUnavailableAlertEnabled = NO;
self.serviceUnavailableAlertTitle = NSLocalizedString(@"Service Unavailable", nil);
self.serviceUnavailableAlertMessage = NSLocalizedString(@"The remote resource is unavailable. Please try again later.", nil);
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(serviceDidBecomeUnavailableNotification:)
name:RKServiceDidBecomeUnavailableNotification
object:nil];
// Configure reachability and queue
[self addObserver:self forKeyPath:@"reachabilityObserver" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
self.requestQueue = [RKRequestQueue requestQueue];
// Configure observers
[self addObserver:self forKeyPath:@"reachabilityObserver" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
[self addObserver:self forKeyPath:@"baseURL" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"requestQueue" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
[self addObserver:self forKeyPath:@"requestQueue" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld | NSKeyValueObservingOptionInitial context:nil];
}
return self;