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
總結
- 上一篇: 水系图一般在哪里找得到_腾远带你了解:虹
- 下一篇: 分享微信预约系统开发制作步骤_教你实现微