NSBundle

  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];
原文地址:https://www.cnblogs.com/codelu/p/5188287.html