美文网首页
Plist文件的创建与数据获取

Plist文件的创建与数据获取

作者: 古月思吉 | 来源:发表于2019-01-20 00:03 被阅读0次
//MARK: - Plist文件相关
extension HomeVC {
    
    //创建“HomePage.plist”文件
    func createHomePagePlistFileWithDict(dict:NSDictionary) {
        let documentsDirectory = FilePathTool.share.documentPath as NSString
        let plistPath = documentsDirectory.appendingPathComponent("HomePage.plist")
        dict.write(toFile: plistPath, atomically: true)
    }
    //获取“HomePage.plist”文件的内容
    func getDictFromHomePagePlist() -> NSDictionary {
        let plistPath = Bundle.main.path(forResource: "HomePage", ofType: "plist")
        let dict = NSDictionary.init(contentsOfFile: plistPath!)
        return dict!
    }
    
}

相关文章

网友评论

      本文标题:Plist文件的创建与数据获取

      本文链接:https://www.haomeiwen.com/subject/bxmtjqtx.html