I want to parse the string below so that each row is put into an array.
I have the following string as a NSString:
(
"2 ripe avocados",
"1/2 small onion, minced",
"1 clove garlic, minced",
"1 small jalape\U00f1o, stems and seeds removed, minced",
"2 tablespoons cilantro leaves, finely chopped",
"1 tablespoon of fresh lime juice",
"1/2 teaspoon coarse salt",
"A dash of freshly grated black pepper",
"1 Roma tomato, chopped",
"4 slices crusty white bread",
"4 slices Cheddar cheese",
"Butter, for buttering bread"
)
I tried the following:
NSCharacterSet* charset = [NSCharacterSet characterSetWithCharactersInString:@"()"];
NSString *newStr = _recipe.ingredients;
newStr = [newStr stringByTrimmingCharactersInSet:charset];
NSArray* array = [newStr componentsSeparatedByString:@"\","];
NSCharacterSet* charset2 = [NSCharacterSet characterSetWithCharactersInString:@"\""];
NSString *ingredientString = [[array objectAtIndex:0] stringByTrimmingCharactersInSet:charset2];
NSLog(@"%@", ingredientString);
But I get a lldb error:
-[__NSCFArray stringByTrimmingCharactersInSet:]: unrecognized selector sent to instance 0x200a8d90
Do I need to retain the ingredients string?