How to get the value from the below output in ios?

这一生的挚爱 提交于 2019-12-25 19:10:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!