How to get Bundle version in shortcut from test-Info.plist project in iphone?

Here I insert my codes where I want to get the Bundle version from my test-Info.plist.

@interface testViewController : UIViewController { UILabel *label; } @property(nonatomic,retain) IBOutlet UILabel *label; @end @implementation testViewController @synthesize label; - (void)viewDidLoad { [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@"test-info" ofType:@"plist"]; NSString *versionString = [NSString stringWithFormat:@"v%d", [plistData objectForKey:@"Bundle version"]]; label.text = versionString; } @end 

But still I got a null value where I am wrong

+4
source share
2 answers

Try to get the plist path by doing the following:

 NSString *path = [[NSBundle mainBundle] pathForResource:@"test-info" ofType:@"plist"]; 
+1
source

The next line will select the version for you

 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]; 
+36
source

Source: https://habr.com/ru/post/1307455/


All Articles