ios - 我可以只从 plist 中读取 key 吗?

标签 ios iphone ipad plist key-value

我可以只从 plist 中读取键而不读取它的值吗?如果我知道该值,我可以读取键吗?

最佳答案

读取.plist:

NSString *path = [[NSBundle mainBundle] pathForResource:@"myPlist" ofType:@"plist"];    
NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:path];

获取所有键和所有值:

NSArray* allmyKeys = [myDictionary  allKeys];
NSArray* allmyValues= [myDictionary  allValues];

获取值对象的所有键:

NSArray* allmyKeys = [myDictionary  allKeysForObject:myValueObject];

关于ios - 我可以只从 plist 中读取 key 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6236494/

相关文章:

ios - iOS 中的 SQLite 数据库安全

ios - 在 Swift 3 中更改 UITextField 中的文本时调用 Web 服务

ios - 如何在与 iPad 和所有 iPhone 屏幕兼容的 React Native 中为 IOS 创建带有全屏图像的 LaunchScreen

iphone - AVPlayerItem replaceCurrentItemWithPlayerItem 阻塞

iphone - 核心数据迁移 "can' t 将模型与名为 'foo' 的两个不同实体合并”

iphone - 从 NSOperation 重新加载 UITableView

ios - 为什么 UINavigationController 和 UIViewControllers 之间没有保留循环

html - 背景图像不显示在 ios 上

iphone - 如何在 OpenGL 中对圆柱体进行纹理映射?

iphone - 移动到 UITableView 行选择的另一个 View