博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

NSBundle

Posted on 2011-07-04 23:59  星尘的天空  阅读(198)  评论(0编辑  收藏  举报

Link URL:http://hi.baidu.com/xtianhe/blog/item/1f1bbe1cbd4c411f35fa41a6.html

NSBundle的对象可以获取应用程序安装目录的附件。

附件包括了,当前应用程序下,所有的文件。(图片、属性列表等) 

获取XML文件

NSString *filePath = [[NSBundle mainBundle] pathForResouse:@"re" ofType:@"xml"];
 
NSData *data = [[NSData alloc] initWithContentsOfFile:filePath];

获取属性列表

NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ViewControllers" ofType:@"plist"]];