码迷,mamicode.com
首页 > 其他好文 > 详细

NSBundle

时间:2016-02-13 21:53:22      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

  bundle是一个目录,其中包含了程序会使用到的资源. 这些资源包含了如图像,声音,编译好的代码,nib文件(用户也会把bundle称为plug-in). 对应bundle,cocoa提供了类NSBundle.

1、获取bundle

+ (NSBundle *)mainBundle;  //app的目录
NSBundle *file = [NSBundle mainBundle];
NSLog(@"%@",file);

技术分享

2、加载plist文件

- (nullable NSString *)pathForResource:(nullable NSString *)name ofType:(nullable NSString *)ext;
NSString *path = [[NSBundle mainBundle] pathForResource:@"app.plist" ofType:nil];
 
NSArray *array = [NSArray arrayWithContentsOfFile:path];

 

3、加载xib文件

AppView *appView = [[[NSBundle mainBundle] loadNibNamed:@"AppView" owner:nil options:nil] lastObject];

 

NSBundle

标签:

原文地址:http://www.cnblogs.com/codelu/p/5188287.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!