1

如果我使用以下方法获取 plist 中的数据:

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);
}

我该如何编写一个条件语句,仅检查是否已检查设置为YES,如果是,则输出提供程序的文本值

4

1 回答 1

1

假设checked存储为BOOL包装在NSNumber*中,您可以使用以下代码:

NSNumber *checked = [dictionary valueForKey:@"checked"];
if ([checked boolValue]) {
    ...
}


*你通过调用BOOL.NSNumber[NSNumber numberWithBool:myBoolValue]

于 2013-01-21T16:04:14.673 回答