问题
I am getting this below output while hitting soap service and now I want to fetch the all value from the below output. How to get this?
[{
"sms": "You have logged in successfully!",
"userId": "13",
"type": "1",
"name": "Suhashini Kumari Singh"
}]
回答1:
You can do something like,
NSArray *yourArr; // your array which you have post in question
NSDictionary *obj1 = [yourArr objectAtIndex:0];
NSString *sms = [obj1 objectForKey:@"sms"];
NSString *userId = [obj1 objectForKey:@"userId"];
NSString *name = [obj1 objectForKey:@"name"];
NSString *type = [obj1 objectForKey:@"type"];
You can go loop through if you have multiple object in array!!!
回答2:
You can create class with needed properties and map this response with framework like EasyMapping
来源:https://stackoverflow.com/questions/39289301/how-to-get-the-value-from-the-below-output-in-ios