1

I'm trying to output the results from the following plist where checked is 1 (checked is a BOOL from the plist). The issue I'm having is that when I try to output the text into a providersArray it outputs them one after another and not in one array like "text1,text2,text3," etc...

My syntax is causing me the problem. any help would be great.

NSString *path = [[NSBundle mainBundle] pathForResource:@"Providers" ofType:@"plist"];
dataArray = [NSMutableArray arrayWithContentsOfFile:path];
for (NSDictionary *dictionary in dataArray)
{
    text = [dictionary valueForKey:@"text"];
    checked = [dictionary valueForKey:@"checked"];
    NSLog(@"%@ checked value is: %@", text, checked);


    if ([checked boolValue]) {
        NSString *providers = [NSString stringWithFormat:@"%@",text ];
        NSLog(@"providers are %@", providers);

       NSArray *providersArray = [text componentsSeparatedByString:@","];

      NSLog(@"providersArray are %@", providersArray);


    }

}
1
  • It's not clear what you're trying to do. Are you trying to separate text into words separated by commas, and put those words into an array? If so, where does the next set of words (from the next dictionary in your for-in loop) go? Commented Jan 21, 2013 at 16:53

1 Answer 1

2

Place NSArray *providersArray out of loop.

To prevent it from getting initialized again and again and lose its previous value, use addObject: on it.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.