Giya
Giya

Reputation: 248

Get multiple values from a web service

I have a webservice, in which the parameter "upload_images" have more than one value. How can i get that values. I am using SBJson. Here is my response

{
    "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"
 }

Upvotes: 0

Views: 60

Answers (2)

Gabriele Petronella
Gabriele Petronella

Reputation: 108111

If I understand your question correctly, upload_images contains a string of comma-separated URLs and you want to extract them.

You can easily achieve this using NSString's method componentsSeparatedByString, for instance

NSString *uploadImages = response[@"upload_images"];
NSArray *imageURLs = [uploadImages componentsSeparatedByString:@", "];

where I assumed response to be a NSDictionary object holding the parsed response.

Upvotes: 1

Suhit Patil
Suhit Patil

Reputation: 12023

you can get the the "upload_images" as the string and can convert in the array using componentsSeparatedByString: method

NSString *uploadImages = [response objectForKey:@"upload_images"];
NSArray *imageUrlArray = [uploadImages componentsSeparatedByString:@", "];

Upvotes: 0

Related Questions