mainBundle和CustomBundle
iOS中NSBundle类
An NSBundle object represents a location in the file system that groups code and resources that can be used in a program. NSBundle objects locate program resources, dynamically load and unload executable code, and assist in localization. You build a bundle in Xcode using one of these project types: Application, Framework, plug-ins. Overview Although bundle structures vary depending on the target platform and the type of bundle you are building, the NSBundle class hides this underlying structure in most (but not all) cases. Many of the methods you use to load resources from a bundle automatically locate the appropriate starting directory and look for resources in known places. For information about application bundle structures (for OS X and iOS), see Bundle Programming Guide. For information about the structure of framework bundles, see Framework Programming Guide. For information about the structure of OS X plug-ins, see Code Loading Programming Topics. For additional information about how to load nib files and images in a Mac app, see NSBundle AppKit Additions Reference. For information about how to load nib files in an iOS application, see NSBundle UIKit Additions Reference. Unlike some other Foundation classes with corresponding Core Foundation names (such as NSString and CFString), NSBundle objects cannot be cast (“toll-free bridged”) to CFBundle references. If you need functionality provided in CFBundle, you can still create a CFBundle and use the CFBundle Reference API. See Interchangeable Data Types for more information on toll-free bridging.
一、mainBundle
获取方法是NSBundle的静态方法:
+ (NSBundle *)mainBundle;
Overview: Returns the NSBundle object that corresponds to the directory where the current application executable is located. The NSBundle object that corresponds to the directory where the application executable is located, or nil if a bundle object could not be created.返回到目录当前的应用程序可执行文件所在的位置相对应的 NSBundle 对象。
info.plist打印:
[[NSBundle mainBundle] infoDictionary]
{
BuildMachineOSBuild = 15B42;
CFBundleDevelopmentRegion = en;
CFBundleExecutable = Vuforia;
CFBundleIcons = {
CFBundlePrimaryIcon = {
CFBundleIconFiles = (
AppIcon29x29,
AppIcon40x40,
AppIcon57x57,
AppIcon60x60
);
};
};
CFBundleIdentifier = "com.vuforia.sample.Vuforia";
CFBundleInfoDictionaryVersion = "6.0";
CFBundleInfoPlistURL = "Info.plist -- file:///var/mobile/Containers/Bundle/Application/37BA0E72-E0C6-4D56-BA12-430F36CED547/Vuforia.app/";
CFBundleName = Vuforia;
CFBundleNumericVersion = ;
CFBundlePackageType = APPL;
CFBundleShortVersionString = "5.0";
CFBundleSignature = "????";
CFBundleSupportedPlatforms = (
iPhoneOS
);
CFBundleVersion = ;
DTCompiler = "com.apple.compilers.llvm.clang.1_0";
DTPlatformBuild = 13C75;
DTPlatformName = iphoneos;
DTPlatformVersion = "9.2";
DTSDKBuild = 13C75;
DTSDKName = "iphoneos9.2";
DTXcode = ;
DTXcodeBuild = 7C68;
LSRequiresIPhoneOS = ;
MinimumOSVersion = "7.0";
UIDeviceFamily = (
,
);
UILaunchImageFile = LaunchImage;
UILaunchImages = (
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Portrait-736h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Landscape-736h";
UILaunchImageOrientation = Landscape;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-667h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{375, 667}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 480}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-568h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 568}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-Portrait";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{768, 1024}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-Landscape";
UILaunchImageOrientation = Landscape;
UILaunchImageSize = "{768, 1024}";
}
);
UIMainStoryboardFile = Main;
UIRequiredDeviceCapabilities = (
armv7
);
UIStatusBarHidden = ;
UISupportedInterfaceOrientations = (
UIInterfaceOrientationPortrait
);
UIViewControllerBasedStatusBarAppearance = ;
}
info.plist打印结果
可以通过这个东西来获得app的info信息。enjoy it:)
二、customBundle
图片的压缩包bundle东西,例如:QQ的app的个性化定制图片资源,一些加载的可执行的代码(这个我没有操作过)。
如何加载customBundle看NSBundle中的公开方法。
mainBundle和CustomBundle的更多相关文章
- iOS [[NSBundle mainBundle] pathForResource:@"" ofType:@""]无法获取到文件
将一个文件导入到工程中后,用[[NSBundle mainBundle] pathForResource:@"" ofType:@""]来获取到该文件时,一直无 ...
- NSBundle的使用,注意mainBundle和Custom Bundle的区别
1.[NSBundle mainBundle],文件夹其实是Group,如左侧的树形文件管理器 Build之后,文件直接就复制到了根目录下,于是读取的方法,应该是这样: NSString *earth ...
- [[NSBundle mainBundle] pathForResource:fileName ofType:]获取文件路径不成功
目标文件明明已经加入项目了,但是使用[[NSBundle mainBundle] pathForResource:fileName ofType:]来获取文件路径的时候却为nil: 遇到这个问题大家需 ...
- IOS NSBundle的使用,注意mainBundle和Custom Bundle的区别
1.[NSBundle mainBundle],文件夹其实是Group,如左侧的树形文件管理器 Build之后,文件直接就复制到了根目录下,于是读取的方法,应该是这样: NSString *earth ...
- IOS NSBundle 的理解和 mainBundle 类方法详解
常看到类似的 NSString *file = [[NSBundle mainBundle] pathForResource:name ofType:nil]; 这样的代码,用来获取 file 的完全 ...
- NSBundle的理解和mainBundle的基本介绍
一.NSBundle NSBundle是cocoa为bundle提供的一个类,bundle是一个目录,其中包含了程序会使用到的资源. 这些资源包含了如图像.声音.编译好的代码.nib文件.(用户也会把 ...
- [[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"] 找不到对应的文件解决方法
最近在使用[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]时,找不到其对应的文件,文 ...
- 【转】NSBundle的使用,注意mainBundle和Custom Bundle的区别
1.[NSBundle mainBundle],文件夹其实是Group,如左侧的树形文件管理器 Build之后,文件直接就复制到了根目录下,于是读取的方法,应该是这样: NSString *earth ...
- iOS 把数据库文件打包到mainbundle中,查找不到路径的解决的方法;以及在删除bundle中文件的可行性
在开发中有时我们须要把数据库文件打包到我们的项目中.一般我们都是在外部用工具生成数据库文件,然后拉入项目中.可是我们在程序中查找改文件时.返回的路径总是nil 解决的方法: 原因我们拉入其它资源文件( ...
随机推荐
- 用Dart&Henson玩转Activity跳转
用Dart&Henson玩转Activity跳转 Extra是Android标准的组件之间(Activity/Fragment/Service等)传递数据的方式.本文介绍了开源项目Dart的使 ...
- 【MVVMLight小记】一.快速搭建一个基于MVVMLight的silverlight小程序
写了篇MVVM小记http://www.cnblogs.com/whosedream/p/mvvmnote1.html,说好要写点MVVMLight的东西,所以接着写,以便和大家共勉. 我假设你已经有 ...
- nios II--实验2——led软件部分
软件开发 首先,在硬件工程文件夹里面新建一个software的文件夹用于放置软件部分:打开toolsàNios II 11.0 Software Build Tools for Eclipse,需要进 ...
- MPLS
Multiprotocol Label Switching From Wikipedia, the free encyclopedia "MPLS" redirects here. ...
- Google 面试
坚持完成这套学习手册,你就可以去 Google 面试了 系统 指针 value Google 面试 阅读10266 本文为掘金投稿,译文出自:掘金翻译计划 原文地址:Google Intervie ...
- cxf和spring结合
服务端: 实体: package entity; import java.util.Date; /*** 实体 */ public class Pojo { //温度 private String d ...
- Qt做动画旋转旋转图片
今天看到百度首页的音乐播放有个图片可以旋转,感觉很酷就用qt做了一个类似的,关键时刻还是要发挥数学功底,静下心来,写一写,画一画,编程对数学分析能力要求还是不小的,以后要经常锻炼数学分析能力啊! Wi ...
- BIM软件小技巧:Revit2014所有快捷键汇总表格
命令 快捷键 路径 修改 MD 创建>选择; 插入>选择; 注释>选择; 视图>选择; 管理>选择; 修改>选择; 建筑>选择; 结构>选择; 系统 ...
- [转]Java日期时间使用总结
原文地址:http://lavasoft.blog.51cto.com/62575/52975/ 一.Java中的日期概述 日期在Java中是一块非常复杂的内容,对于一个日期在不同的语言国别环境中 ...
- DOS常用命令收集(长期更新)
命令列表 命令 说明 ASSOC 显示或修改文件扩展名关联. ATTRIB 显示或更改文件属性. BREAK 设置或清除扩展式 CTRL+C 检查. BCDEDIT 设置启动数据库中的属性以控制启动加 ...