码迷,mamicode.com
首页 > 其他好文 > 详细

mainBundle和CustomBundle

时间:2015-12-29 14:26:01      阅读:552      评论:0      收藏:0      [点我收藏+]

标签:

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.
View Code

一、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 = 16809984;
    CFBundlePackageType = APPL;
    CFBundleShortVersionString = "5.0";
    CFBundleSignature = "????";
    CFBundleSupportedPlatforms =     (
        iPhoneOS
    );
    CFBundleVersion = 1;
    DTCompiler = "com.apple.compilers.llvm.clang.1_0";
    DTPlatformBuild = 13C75;
    DTPlatformName = iphoneos;
    DTPlatformVersion = "9.2";
    DTSDKBuild = 13C75;
    DTSDKName = "iphoneos9.2";
    DTXcode = 0720;
    DTXcodeBuild = 7C68;
    LSRequiresIPhoneOS = 1;
    MinimumOSVersion = "7.0";
    UIDeviceFamily =     (
        1,
        2
    );
    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 = 1;
    UISupportedInterfaceOrientations =     (
        UIInterfaceOrientationPortrait
    );
    UIViewControllerBasedStatusBarAppearance = 0;
}
info.plist打印结果

可以通过这个东西来获得app的info信息。enjoy it:)

二、customBundle

图片的压缩包bundle东西,例如:QQ的app的个性化定制图片资源,一些加载的可执行的代码(这个我没有操作过)。

如何加载customBundle看NSBundle中的公开方法。

mainBundle和CustomBundle

标签:

原文地址:http://www.cnblogs.com/R0SS/p/5085495.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!