首页 > 其他 > 详细

dictionaryWithContentsOfFile:方法

时间:2014-03-25 07:23:04      阅读:1700      评论:0      收藏:0      [点我收藏+]

dictionaryWithContentsOfFile:方法的功能是创建一个字典,将字典中的内容设置为指定文件中的所有内容,

语法:(id)dictionaryWithContentsOffilE.

网上对该方法说的都不请,dictionaryWithContentsOfFile和arryWithContentsOfFile都可以用来读取文件中的内容。

个人认为arrWithContensOfFile强大些。

本人今天对比下他们的不同

分别用两种方法来实现文件的读取

代码如下:

  

bubuko.com,布布扣
  { //获取imageData.plist文件的主路径
NSBundle
*baudel= [NSBundle mainBundle]; // NSString *path=[baudel pathForResource:@"imageData" ofType:@"plist"];
NSString *path1=[baudel pathForResource:@"imageData1" ofType:@"plist"];
//_Images=[NSArray arrayWithContentsOfFile:path];

_Images=[NSMutableDictionarydictionaryWithContentsOfFile:path1]; }
bubuko.com,布布扣
如果我们使用dictionaryWithContentsOfFile,那我们plist设定的文件类型就是这样

bubuko.com,布布扣

而【arrayWithContentsOfFile:path】方法,
bubuko.com,布布扣
对比一下,我们就可以发现,一般来说如果对象多,我们可以采用arryWithofFile来实现。因为在数组中我们可以放字典。

dictionaryWithContentsOfFile:方法,布布扣,bubuko.com

dictionaryWithContentsOfFile:方法

原文:http://www.cnblogs.com/zhyios/p/3622277.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!