NSBundle
来源:互联网 发布:九阴绝学声望回收数据 编辑:程序博客网 时间:2024/05/17 07:03
1.获取app的info.plist详细信息
版本号:Bundle version
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
应用标识:Bundle identifier
NSString *bundleId = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
应用名称:Bundle display name
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
Bundle name
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
2.应用程序语言本地化
app本地化宏
#define XLocalizedString(key, comment) [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]
中英文两个Localizable.strings文件中键值对,例如
"none" = "确定";
"none" = "none";
宏的用法:(返回NSString *)
localizedString("none", "这是注释")
3.获取包内文件路径和文件
获取app包路径
NSString *path = [[NSBundle mainBundle] bundlePath];
app资源目录路径
NSString *resPath = [[NSBundle mainBundle] resourcePath];
获取资源目录下a.bundle
NSString* path = [resPath stringByAppendingPathComponent:@"a.bundle"];NSBundle *bundle = [NSBundle bundleWithPath:path];
获取app包的readme.txt文件路径
NSString *path = [[NSBundle mainBundle] pathForResource:@"readme" ofType:@"txt"];
0 0
- nsbundle
- nsbundle
- NSBundle
- NSBundle
- nsbundle
- NSBundle
- NSBundle
- NSBundle
- NSBundle
- NSBundle
- NSBundle
- NSBundle
- NSBundle
- NSBundle
- nsbundle
- NSBundle
- NSBundle
- NSbundle
- smarty
- 关于使用FileStream读写文件
- pdo
- [无异常,才正常]java.lang.ClassNotFoundException: org.apache.catalina.startup.VersionLoggerListener
- res/raw和assets的区别
- NSBundle
- maven 那点事儿(eclipse)
- 使用批处理命令bat文件快速一键启动mysql
- Yii 2.0加载自定义类或命名空间
- FZU 1402 猪的安家 (中国剩余定理)
- MLiA SVM心得
- CentOS下删除或重命名乱码文件
- 《Learning Javascript Design Patterns》小结
- 深入浅出的讲解傅里叶变换(真正的通俗易懂)