您的位置:首页 > 移动开发 > IOS开发

IOS开发——在程序中获取Info.plist中的字段

2015-01-19 12:39 1111 查看
IOS开发——获取版本号
获取版本号:


- (void)viewDidLoad
{
[super viewDidLoad];
//获取版本号
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:bundlePath];
NSString *version = [dict objectForKey:@"CFBundleShortVersionString"];

_mVersionLabel.text  = version;
}

或者:

- (void)viewDidLoad {
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSLog(@"%@",infoDict);
NSString *executableFile = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey];
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey];
}



打印:

Printing description of dict:

{

    CFBundleDevelopmentRegion = en;

    CFBundleDisplayName = "\U5168\U7403\U8f66\U5c55\U5feb\U62a5";

    CFBundleExecutable = "Palmtrends_qqcz_1.0.0";

    CFBundleIconFiles =     (

        "Icon.png",

        "Icon@2x.png",

        "Icon-Small.png",

        "Icon-Small@2x.png",

        "Icon-Small-50.png",

        "Icon-Small-50@2x.png",

        "Icon-72.png",

        "Icon-72@2x.png"

    );

    CFBundleIdentifier = "com.pal****.qq****";

    CFBundleInfoDictionaryVersion = "6.0";

    CFBundleName = "\U5168\U7403\U8f66\U5c55\U5feb\U62a5";

    CFBundlePackageType = APPL;

    CFBundleShortVersionString = "1.0.2";

    CFBundleSignature = "????";

    CFBundleSupportedPlatforms =     (

        iPhoneSimulator

    );

    CFBundleURLTypes =     (

                {

            CFBundleTypeRole = Editor;

            CFBundleURLName = "yybj_weixin";

            CFBundleURLSchemes =             (

                wxc53e31e71e69****

            );

        },

                {

            CFBundleTypeRole = Editor;

            CFBundleURLName = "com.weibo";

            CFBundleURLSchemes =             (

                wb13280****

            );

        }

    );

    CFBundleVersion = "1.0.2.1";

    DTPlatformName = iphonesimulator;

    DTSDKName = "iphonesimulator8.1";

    LSRequiresIPhoneOS = 1;

    UIDeviceFamily =     (

        1

    );

    UIPrerenderedIcon = 1;

    UIRequiredDeviceCapabilities =     (

        armv7

    );

    UIStatusBarHidden = 1;

    UISupportedInterfaceOrientations =     (

        UIInterfaceOrientationPortrait,

        UIInterfaceOrientationLandscapeLeft,

        UIInterfaceOrientationLandscapeRight

    );

    UIViewControllerBasedStatusBarAppearance = 0;

}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: