【问题标题】:iOS Framework - get plist into a dictionaryiOS 框架 - 将 plist 放入字典
【发布时间】:2020-11-23 19:45:36
【问题描述】:

我正在创建一个 iOS - 框架 (swift) 我有这个函数——我用它来检索一个应该包含所有 lib 属性(字符串)的字典

func getPropertyList() -> [String: Any]?{
    let path = Bundle.main.path(forResource: "properties", ofType: "plist")!
    let dict = NSDictionary(contentsOfFile: path) as? [String: Any]
    return dict
}

从测试这条线一直返回nil

Bundle.main.path(forResource: "properties", ofType: "plist")!

即使 properties.plist 文件位于“复制捆绑资源”中 并选择了目标成员

【问题讨论】:

    标签: ios swift plist


    【解决方案1】:

    使用

    let path = Bundle(identifier:"com.example.frameworkID")!.path(forResource: "properties", ofType: "plist")!
    

    【讨论】:

      猜你喜欢
      • 2017-05-29
      • 1970-01-01
      • 1970-01-01
      • 2012-07-19
      • 1970-01-01
      • 2017-09-01
      • 2013-02-26
      • 2018-08-25
      • 1970-01-01
      相关资源
      最近更新 更多