1.NSBundle
1> 一个NSBundle代表一个文件夹,利用NSBundle能访问对应的文件夹
2> 利用mainBundle就可以访问软件资源包中的任何资源
3> 模拟器应用程序的安装路径 /Users/aplle/资源库/Application Support/iPhone Simulator/7.1/Applications
4>实现懒加载 只加载一次
@proper...
分类:
移动开发 时间:
2014-12-24 01:19:02
阅读次数:
247
swift:
NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"]
比如:
if let version = NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"] as? String {
...
分类:
其他好文 时间:
2014-12-18 22:20:09
阅读次数:
192
一、加载xib文件的两种方式1.方法一(NewsCell是xib文件的名称)NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@“NewsCell” owner:nil options:nil];2.方法二UINib *nib = [UIN...
分类:
其他好文 时间:
2014-12-16 20:50:06
阅读次数:
166
1.判断数据集是否为空,如果为空加载数据,否则不需要加载数据。-(NSArray *)roles{ if (_roles == nil) { //获取数据文件 NSString *path = [[NSBundle mainBundle]pat...
分类:
其他好文 时间:
2014-12-11 22:11:36
阅读次数:
175
昨天手贱去设置了info.plist中“Localization native development region”属性,今天过来发现app有些页面打不开,提示Could not load NIB in bundle: ‘NSBundle (loaded)‘错误。 找遍了网上的各种解决方案,后来...
分类:
其他好文 时间:
2014-12-11 12:33:14
阅读次数:
116
// 当服务端接口没做好时,本地可以构造假数据,并转换为json数据
NSError *error;
NSString *dataStr = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"indEditor" ofType:@"txt"] encoding:NSUTF8Stri...
分类:
移动开发 时间:
2014-12-11 12:31:02
阅读次数:
148
bundle是一个目录,其中包含了程序会使用到的资源. 这些资源包含了如图像,声音,编译好的代码,nib文件(用户也会把bundle称为plug-in). 对应bundle,cocoa提供了类NSBundle.我们的程序是一个bundle. 在Finder中,一个应用程序看上去和其他文件没有什么区别...
分类:
其他好文 时间:
2014-12-06 10:06:04
阅读次数:
128
NSBundle一.获取图片1. NSString *path = [[NSBundle mainBundle] pathForResource:@"resourceName" ofType:@“resourceType"]; UIImage *image = [[UIImageimageW...
分类:
其他好文 时间:
2014-12-05 10:32:35
阅读次数:
160
//从budle路径下读取音频文件 轻音乐 - 萨克斯回家 这个文件名是你的歌曲名字,mp3是你的音频格式NSString *string = [[NSBundle mainBundle] pathForResource:@"轻音乐 - 萨克斯回家" ofType:@"mp3"];//把音频文件转....
分类:
其他好文 时间:
2014-12-03 12:06:26
阅读次数:
163
不要用imageNamed用这个方法,内存不会清理的NSString *path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"png"];myImage = [UIImage imageWithContentsOfFile:pa...
分类:
其他好文 时间:
2014-11-28 17:58:29
阅读次数:
101