I am trying to get my version number of my app using:
NSString * version = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
but it crashes with this error:
[NSString stringWithUTF8String:]: NULL cString
What am I doing wrong?
Check your info.plist to make sure short version (CFBundleShortVersionString) or (Bundle versions string, short) is set.
Your code is fine. But you can also call it this way:
NSString * version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.