如何使用Swift读取文档文件夹中的plist?

问题描述

我想阅读我的文档文件夹中的plist。但是,当我尝试阅读字典时,Xcode抛出一个错误,它为nil。

func getPlist() {
    let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory,.userDomainMask,true)[0] as Nsstring
    let sourcePath = documentsPath.appendingPathComponent("Sample.plist")
    let dictionary = NSDictionary(contentsOfFile: sourcePath as String)
    for (key,value) in dictionary!{
        print("Key : \(key) Value : \(value)")
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)