0

I am fairly new to iOS development and I have been trying to figure out how I can convert the following string into an array and then displaying that array in a UITableView

{"Result":"OK","Users":[{"name":"The King","email":"[email protected]"},{"name":"The Resteruant","email":"[email protected]"}]}

What I want to get is an array for the "name" and a separate array for "email"

This is what i have so far:

    strURL    = [NSString stringWithFormat:@"http://10.139.10.43/Wolfeboro_Connection/get_business.php"];
    dataURL   = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
    strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];

    NSLog(@"%@", strResult);

I have installed a JSON library but I dont know how to use it and how I can get the arrays. Please help with examples.

EDIT: Found a great tutorial that helped me with this problem

http://www.youtube.com/watch?v=RJZcD3hfs3k

1 Answer 1

0

This might help you. "What you have here is a dictionary containing key/values, where values are also dictionaries. If you need to have an array containing, say value_b, of each of these dictionaries you can have it like this"

Save JSON data in a NSArray

Sign up to request clarification or add additional context in comments.

3 Comments

ok in the link you provided me there is one line of code that is confusing me. NSDictionary *products = [json objectForKey:@"products"]; in this line of code what does the "json" stand for? Xcode is giving me the error of "Use of undeclared identifier json"
Never mind i found a great tutorial that helped me out youtube.com/watch?v=RJZcD3hfs3k
Awesome. Sorry I didn't see this response sooner.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.