我有一个web服务,其中参数“upload_images”具有多个值。我怎样才能获得这些价值观。我正在使用SBJson。这是我的回复
{
"node_title": "thk",
"category": "Boating",
"description": "Fg",
"link": "",
"nid": "446",
"post date": "Mon, 11/25/2013 - 07:04",
"upload_images": "http://prod.kyzook.com/?q=sites/prod.kyzook.com/files/styles/medium/public/2013-11-25%2007%3A03%3A25%20%2B0000.png&itok=WIBTqzbC, http://prod.kyzook.com/?q=sites/prod.kyzook.com/files/styles/medium/public/2013-11-25%2007%3A03%3A58%20%2B0000.png&itok=AhoLUnou"
}
答案 0 :(得分:1)
如果我正确理解您的问题,upload_images
包含一串逗号分隔的网址,您想要提取它们。
您可以使用NSString
的方法componentsSeparatedByString
轻松实现此目的,例如
NSString *uploadImages = response[@"upload_images"];
NSArray *imageURLs = [uploadImages componentsSeparatedByString:@", "];
我假设response
是一个持有解析后的响应的NSDictionary
对象。
答案 1 :(得分:0)
您可以将"upload_images"
作为string
获取,并使用array
方法转换为componentsSeparatedByString:
NSString *uploadImages = [response objectForKey:@"upload_images"];
NSArray *imageUrlArray = [uploadImages componentsSeparatedByString:@", "];