IPhone应用开发中NSBundle使用

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

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

获取XML文件

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


获取属性列表

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

posted @ 2012-08-17 23:04  careerman  阅读(139)  评论(0编辑  收藏  举报