gpt4 book ai didi

ios - 读取 plist 文件。 iOS编程

转载 作者:行者123 更新时间:2023-11-29 11:19:00 24 4
gpt4 key购买 nike

我有这段代码,但无法弄清楚我做错了什么。正如您在下面的代码中看到的,我有一个名为 shifts.plist 的 plist 文件,它位于我的 supporting files 文件夹中。这是我的 plist 结构。
enter image description here

    NSString *path = [[NSBundle mainBundle] pathForResource:@"shifts" ofType:@"plist"];
dictionary = [[NSMutableDictionary alloc]initWithContentsOfFile:path];
cell.textLabel.text = [secondTableInfo objectAtIndex:indexPath.row];
NSLog(@"%@",[[dictionary objectForKey:@"name"]objectAtIndex:0]);

我最终想读取 name 条目并用它们填充 UITableView
我使用 NSLog 输出 dictionary 并得到以下结果。所以文件就在那里我出错的解析。
NSLog output
谢谢,
山姆

最佳答案

看起来您需要先调用 objectAtIndex:,然后再调用 objectForKey:

例如:

[[dictionary objectAtIndex:0] objectForKey:@"Name"]

关于ios - 读取 plist 文件。 iOS编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8146023/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com