Cowboy Tech

iOS数据存储-plist文件

读取数组

let arr = NSArray(contentsOfURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("arr", ofType: "plist")!))
print(arr)

读取字典

let dict = NSDictionary(contentsOfURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("data", ofType: "plist")!))
print(dict)

let name:String = dict!["name"] as! String
print("name : \(name)")