How do I get the current version of my iOS project in code?

后端 未结 8 1348
挽巷
挽巷 2020-12-12 10:23

I would like to be able to get the current version of my iOS project/app as an NSString object without having to define a constant in a file somewhere. I don\'t

8条回答
  •  余生分开走
    2020-12-12 11:00

    In Objective C:

    1)For getting App version you have to use a:

    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    

    2)For getting Build version you have to use a:

    NSString *buildVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; 
    

提交回复
热议问题