Created
December 13, 2012 16:10
-
-
Save yoghi/4277504 to your computer and use it in GitHub Desktop.
RestKit connect to rest service behind basic autentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *url = @"http://rest.local/test"; | |
NSURL *baseURL = [NSURL URLWithString:url]; | |
AFHTTPClient* client = [[AFHTTPClient alloc] initWithBaseURL:baseURL]; | |
[client setAuthorizationHeaderWithUsername:@"demo" password:@"demo"]; | |
[client setDefaultHeader:@"Accept" value:RKMIMETypeJSON]; | |
RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client]; | |
[RKObjectManager setSharedManager:objectManager]; | |
NSURLRequest *request = [NSURLRequest requestWithURL:baseURL]; | |
RKObjectRequestOperation *operation = [objectManager objectRequestOperationWithRequest:request success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { | |
NSLog(@"ok"); | |
} failure:^(RKObjectRequestOperation *operation, NSError *error) { | |
NSLog(@"not ok"); | |
}]; | |
[operation start]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment