Swift 2 iOS 9:Plist读写 [英] Swift 2 iOS 9: Plist Reading and Writing

查看:116
本文介绍了Swift 2 iOS 9:Plist读写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信Swift 2内的某些情况已经发生了变化,因为似乎没有关于如何读写属性列表的教程起作用.

I believe something has changed within Swift 2, because no tutorials on how to read and write to property lists seem to be working.

为iOS 9开发的任何人都可以在Xcode 7上使用Swift 2将其读/写方法与Plists共享吗?

Can anyone whose developing for iOS 9 share their method of R/W to Plists using Swift 2 on Xcode 7?

推荐答案

这在iOS 9和Xcode 7上对我有效:

This is working for me on iOS 9 and Xcode 7:

let filePath = NSBundle.mainBundle().pathForResource("FileName", ofType: "plist")!    
let stylesheet = NSDictionary(contentsOfFile:filePath)

唯一的结果是结果是NSDictionary而不是Dictionary.

The only thing is that the result is NSDictionary and not Dictionary.

这篇关于Swift 2 iOS 9:Plist读写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆