NSBundle
2016-07-04 00:30
246 查看
1.获取app的info.plist详细信息
版本号:Bundle version
应用标识:Bundle identifier
应用名称:Bundle display name
Bundle name
2.应用程序语言本地化
app本地化宏
中英文两个Localizable.strings文件中键值对,例如
宏的用法:(返回NSString *)
3.获取包内文件路径和文件
获取app包路径
app资源目录路径
获取资源目录下a.bundle
获取app包的readme.txt文件路径
版本号: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"];
相关文章推荐
- javascript的数据类型
- res/raw和assets的区别
- 数据库事务的解读
- 学习git
- 用Okhttp框架登录之后的Cookie设置到webView中(转)
- pdo
- [无异常,才正常]java.lang.ClassNotFoundException: org.apache.catalina.startup.VersionLoggerListener
- 餐厅项目增加餐桌
- 关于使用FileStream读写文件
- smarty
- 环信
- 二维树状数组_POJ2155_Matrix
- 数组处理
- 毕设开发中细节总结
- 安卓学习笔记(一)TextView与EditText
- Android开发笔记之Jni编程第二弹
- 数据结构笔记:线性表顺序存储结构(C语言)
- python 发送邮件模块
- 爆栈之前端工程化技术小结(备案)
- 第一章 C++基本认识