Plist到NSDictionary

Syn*_*ror 1 cocoa-touch nsdate uidatepicker plist ios

我有一些plist数据,如下图所示:

在此输入图像描述

如果在我的上选择了等于CDate的NSDate,如何访问"Text"值UIDatePicker

小智 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
    }
}
Run Code Online (Sandbox Code Playgroud)