I am a beginner in xcode please help me How to get the user name & Password from the web service and how to validate it when the sign in button is pressed? Thanks in advance..
How to Access json web services?
857 Views Asked by Ragul At
3
There are 3 best solutions below
2
On
You can't access "json web services". You can recieve awnseres from a web service in json format. Do you even know how to acces the web services? Do you have coded it? Please describe better!
To try to awnser your question anyway, if, for example your service is written in WCF. And your method is called "getUserNamePassword" you would call it with a http request incl your methodname. For example: localhost/Myservice.svc/getUserNamePassword. That would return Json if you setup the config file from wcf right.
Greets
1
On
You can use this code and fetch data from array by using valueForKey method
NSArray *arr1=[NSJSONSerialization JSONObjectWithData:responseData
options:NSJSONReadingAllowFragments error:&error];
NSArray *epi=([arr1 valueForKey:@"Response"]);
NSString *genderString=[[epi objectAtIndex:0] valueForKey:@"username"] ;
Happy Coding :) Hope this will help you..
Refer these Links and you'll be fine.
iPhone/iOS JSON parsing tutorial
JSON Parsing in iOS 7
As far as validating your username and password is concerned, first of all, you'll have to parse and store your data in NSArray or NSDictionary and then extract the needed data from it. Then you can check if the received data is correct or not by comparing it with the expected data. Try doing something like this. This is not the exact solution and you'll have to work around your way.
Now you have your data in the array and extract it out using
objectForKeyorvalueForKey.