swift plist文件

来源:互联网 发布:网络恐怖主义案例 编辑:程序博客网 时间:2024/05/28 15:12

1.创建pliet文件

new file->Resource->Property List 输入plist文件名称

 

2.Root 和Item的设置

Root类型设置为Array, item类型设置为dictionary,

3. 

        var CellInfor : NSMutableArray!

        let bundle = NSBundle.mainBundle() // 创建bundle        let plistPath : String! = bundle.pathForResource("videos", ofType: "plist")//videos  MyCellInfor // 初始化plist文件路径        CellInfor = NSMutableArray(contentsOfFile: plistPath) //将plist文件中的内容读入<span style="font-family: Arial, Helvetica, sans-serif;">MutableArray</span>

4.读取

        let row = indexPath.row        let rowDict : NSDictionary = CellInfor.objectAtIndex(row) as! NSDictionary                cell.MyCellTitle.text = rowDict.objectForKey("Title") as? String        cell.MyCellDetail.text = rowDict.objectForKey("Detail") as? String






0 0
原创粉丝点击