我有一些plist数据,如下图所示:
如果在UIDatePicker
上选择了等于CDate的NSDate,我如何访问“文本”值?
答案 0 :(得分:12)
所以你基本上想要
NSString* path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"plist"];
NSArray* a = [NSArray arrayWithContentsOfFile:path];
for (NSDictionary *d in a)
{
NSString *cdate = [d objectForKey:@"CDate"];
if ([cdate isEqualToString:@"Whatever is currently selected"])
{
NSString *text = [d objectForKey:@"Text"];
// do something with text here
}
}
答案 1 :(得分:1)
偶然发现了这一点并认为更新已到期
NSDictionary *initialDefaults = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Defaults" ofType:@"plist"]];