iOS之NSBundle使用
来源:互联网 发布:深圳淘宝网店推广培训 编辑:程序博客网 时间:2024/06/04 14:02
bundle是一个目录,其中包含了程序会使用到的资源. 这些资源包含了如图像,声音,编译好的代码,nib文件;(首先获得目录,才能使用里面的资源文件)
(1)获得bundle
NSBundle bundle = [NSBundle maiBundle];//获得资源文件;
NSBundle otherBundle = [NSBundle bundleWithPath:@"~/.myApp/Good.bundle"];// 通过路径获取资源
(2)有了bundle之后,访问bundle中的资源
NSString *path = [bundle pathForResource:@"name of the file" ofType:@"plist"];//获得属性列表文件
NSString *path = [bundle pathForResource:@"name of the file" ofType:@"xml"];//获得xml文件
NSImage image = [[NSImage alloc] initWithContentsOfFile:path];
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
代码示例:(得到属性列表中的data)
NSBundle bundle = [NSBundle maiBundle];
NSString *path = [bundle pathForResource:@"name of the file" ofType:@"plist"];
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
- iOS之NSBundle使用
- iOS之NSBundle使用
- IOS 之 NSBundle 使用
- IOS 之 NSBundle 使用
- IOS 之 NSBundle 使用
- iOS开发之NSBundle使用
- iOS学习之NSBundle介绍和使用
- iOS学习之NSBundle介绍和使用
- iOS学习之NSBundle介绍和使用
- iOS开发之NSBundle的使用详解
- IOS学习之NSBundle介绍和使用
- iOS学习之NSBundle介绍和使用
- IOS之NSBundle的使用详解
- iOS开发区之NSBundle
- IOS之NSBundle
- iOS之NSBundle简介
- ios开发之NSBundle
- 3.ios之NSBundle和plist的使用
- 数组
- BAT批处理文件的后台运行不弹出窗口
- iOS Document Interaction 编程指南
- android 在service中使用toast
- DDR内存参数笔记
- iOS之NSBundle使用
- Qt 字符串QString arg()用法总结
- android SQLite 优化
- setContentView()和inflate区别
- ecshop 安装 搬迁
- spring mvc 上传图片
- vim配置文件 .vimrc 。按照那篇将vim打造成IDE来的,成功加入各项功能,另外改善了书签不能保存的情况
- 安装Oracle 11g r2先决条件检查失败解决方法
- 6410平台上配置DDR的参数