Reputation: 701
My app uses a web service in which you scan a food item which returns a UPC number. I feed this number into the web service, and i get all the details about that specific food. I grabbed the "ingredients" and turned it into an array called "ingredients".
This is the value of my array:
ingredientsArray = dataDictionary[@"nf_ingredient_statement"];
When I NSLog my [ingredients description] value, it looks like this:
Distilled Vinegar, Water, #1 Grade Mustard Seed, Salt, Turmeric, Paprika, Spice, Natural Flavors and Garlic Powder.
My question is how can I turn that string into an array which will populate the table view?
Upvotes: 0
Views: 101
Reputation: 9835
IF you want to turn a comma-separated string into an array, here is how you do it, assuming the string is separated by a comma and then a space.
NSString *exampleString = @"one, two, three";
NSArray *exampleArray = [exampleString componentsSeparatedByString:@", "];
Produces:
2014-08-25 23:01:26.561 Testing[60889:3946435] (
one,
two,
three
)
I'm not confident based on your post/comment if you're dealing with an array or a string, but if I were you I would NSLog(@"%@", [ingredientsArray class]); to see what class the object you think you have is.
Upvotes: 2