diff options
Diffstat (limited to 'Juick/APIClient.m')
-rw-r--r-- | Juick/APIClient.m | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Juick/APIClient.m b/Juick/APIClient.m index b812057..ae2ebad 100644 --- a/Juick/APIClient.m +++ b/Juick/APIClient.m @@ -31,10 +31,6 @@ self.manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:baseURLString]]; self.manager.requestSerializer = [AFJSONRequestSerializer new]; [self.manager.requestSerializer setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; - NSString *username = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"]; - if (username) { - [self.manager.requestSerializer setAuthorizationHeaderFieldWithUsername:username password:[SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"]]; - } self.backgroundQueue = [NSOperationQueue new]; self.dateFormatter = [[NSDateFormatter alloc] init]; self.dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss"; @@ -43,6 +39,16 @@ return self; } +-(AFHTTPSessionManager *) manager { + NSString *username = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.username"]; + if (username) { + [_manager.requestSerializer + setAuthorizationHeaderFieldWithUsername:username + password:[SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"]]; + } + return _manager; +} + -(void) pullNextFromPath:(NSString *)path params:(NSDictionary *) params callback:(void(^)(NSArray *, NSError *))callback { AFHTTPSessionManager *manager = [APIClient sharedClient].manager; [self.backgroundQueue addOperationWithBlock:^{ |