我是 ios 开发中的新人,我无法从使用以前的方法创建的 plist 中读取值。read 方法返回 (null) (null)。谁能帮我?
在这里,我创建了一个 plist:
- (void)createAppPlist {
    plistPath = [self getDataFileDir];
    // Create the data structure
    rootElement = [NSMutableDictionary dictionaryWithCapacity:3];
    NSError *err;
    name = @"North America";
    country = @"United States";
    continentElement = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:name, country, nil] forKeys:[NSArray arrayWithObjects:@"Name", @"Country", nil]];
    [rootElement setObject:continentElement forKey:@"Continent"];
    //Create plist file and serialize XML
    data = [NSPropertyListSerialization dataWithPropertyList:rootElement format:NSPropertyListXMLFormat_v1_0 options:0 error:&err];
    if(data)
    {
        [data writeToFile:plistPath atomically:YES];
    } else {
        NSLog(@"An error has occures %@", err);
    }
    NSLog(@"%@", rootElement);
    NSLog(@"%@", data);
}
在这里我试图获得价值..
-(void)readAppPlist
{
    plistPath = [self getDataFileDir];
    NSMutableDictionary *propertyDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
    name = [propertyDict objectForKey:@"Name"];
    country = [propertyDict objectForKey:@"Country"];
    NSLog(@"%@     %@", name, country);
}