黑马程序员——读取Plist文件

 

 -iOS培训,iOS学习-------型技术博客、期待与您交流!------------

读取Plist文件

   

一:新建一个plist文件,并将plist文件数据填入plist文件中,这里plist文件的使用我就不说了,请参考相关文档(注:plist文件是一Dictionary为根节点,Dictionary里面放有很多数组,再在数组中存放你想要的数据)

 

二:读取plsit文件我们这里用到了一个懒加载代码如下

-(NSArray *)data

{

        if(_data == nil)

        {

                 NSBundle *bundle = [NSBundle mainBundle];

                NSString *path = [bundle pathForResource:@"plsitname" ofType:@"plsit"];

                _data = [NSArray arrayWithContentOfFile:path];

         }

        return _data 

}

 

posted on 2015-04-13 19:50  Love-Coder  阅读(182)  评论(0编辑  收藏  举报

导航