Reputation: 6614
If I'm grabbing the data in a plist using:
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);
}
How might I go about writing a conditional statement that checks to see only if checked is set to YES and if so output the text value of the providers
Upvotes: 1
Views: 190
Reputation: 726599
Assuming that checked
is stored as a BOOL
wrapped in NSNumber
*, you can use this code:
NSNumber *checked = [dictionary valueForKey:@"checked"];
if ([checked boolValue]) {
...
}
BOOL
in NSNumber
by calling [NSNumber numberWithBool:myBoolValue]
.
Upvotes: 1