![](/img/trans.png)
[英]How do I access other installed apps' info.plist in iOS programmatically?
[英]How do I access a certain info.plist?
我有多個info.plist
文件,並希望以編程方式訪問它們。 我在這里閱讀了如何做到這一點:
https://sarunw.com/posts/how-to-read-info-plist/
但是當我嘗試:
let infoPlistPath = Bundle.main.url(forResource: "Myplist-Info", withExtension: "plist")
print(infoPlistPath)
它返回零。
我嘗試將plist
添加到相應的目標,結果相同。 我也嘗試將plist
添加到設置copy bundle resource
。 但它仍然返回零。
我該如何做到這一點?
我已附上代碼以獲取 Info.plist 的所有屬性。
func getDataFromInfoPlist(){
if let path = Bundle.main.path(forResource: "Info", ofType: "plist") {
let infoListValue = NSDictionary(contentsOfFile: path)
do {
let JsonData = try JSONSerialization.data(withJSONObject: infoListValue as Any, options: .prettyPrinted)
let val = NSString(data: JsonData, encoding: String.Encoding.utf8.rawValue)! as String
print(val)
} catch {
print(error.localizedDescription)
}
}
print(nsDictionary as Any)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.