Plist文件的创建与数据获取

2019-01-20  本文已影响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!
    }
    
}
上一篇 下一篇

猜你喜欢

热点阅读