Reputation: 2824
I am very new to iOS development. This is my first application and I am in big trouble. I do not know how to start with RestKit. I am trying to implement RestKit authentication in my iOS App since past 3 weeks. I looked around for many solutions but everyone has given a different approach, so could not able to extract which will be useful for me.
I have web services ready which I already use in my Android application. Now I want to make use of same web services for iOS.
So for authentication, I have a login service which takes username and password as parameters. It returns a boolean value (not JSON or XML, but simply true or false). So I did not found any solution on how to handle boolean kind of response from web server.
If anybody can help me to sort out this problem. If anyone has implemented similar kind of behavior then please help me on how to start with rest kit. i.e how to send request and how to access response send by the server.
I have provided piece of code which I tried to implement.
RKURL * baseUrl = [RKURL URLWithBaseURLString:@"https://webserver.org/login"];
RKObjectManager * objectManager = [RKObjectManager objectManagerWithBaseURL:baseUrl];
objectManager.client.username = txtUserName.text;
objectManager.client.password = txtPassword.text;
objectManager.client.authenticationType = RKRequestAuthenticationTypeHTTPBasic;
objectManager.client.disableCertificateValidation = YES;
[objectManager loadObjectsAtResourcePath:[NSString stringWithFormat:@"%@?%@", [baseUrl resourcePath], nil] delegate:self];
Thanks in advance, Any kind of help will be appreciated.
Upvotes: 1
Views: 2305
Reputation: 5066
If your backend does not return an object (xml or json) there's no point to use RKObjectManager
. Instead, try sending the request directly with RKClient
's get:queryParameters:delegate:
selector which gives you lower level API compared to RKObjectManager
.
Also, you said your WS takes username and password as input - if you set username and password properties on RKClient
the credentials will be used for basic HTTP Auth. the queryParameters
dictionary should hold any input parameters for your web services.
Example:
[[RKClient sharedClient] get:myResource queryParameters:params delegate:self];
be sure to implement the delegate
- (void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response
for more detail refer to the documentation.
Upvotes: 1