您可以从主束plist中,把下面的代码在viewDidLoad中读取的值,方法,请注意,在主束中的所有文件只有当你想写的任何读数据的plist,那么你必须把它复制到应用程序的文件目录
NSString *bundle = [[NSBundle mainBundle] pathForResource:@”test” ofType:@”plist”];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:bundle];
NSString *productName = [dict objectForKey:@"ProductName"];
NSString * appVersion = [dict objectForKey:@"AppVersion"];
另一种方法是看应用程序性能
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
NSString appVersion = [NSString stringWithFormat:@"Version %@ (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"], kRevisionNumber];
希望它能帮助!
来源
2014-10-28 20:02:01
ZAZ
感谢您的回复。在这里你告诉了从test.plist读取的值。没关系。但是,我如何在目标文件的“生成设置”中使用这些值。 – 2014-10-28 20:13:15
看到我的第二个答案,它从项目的info.plist中读取值 – ZAZ 2014-10-28 20:31:01
是的,我们可以阅读它。但是,我如何从Target的Build Settings中访问? – 2014-10-28 20:55:52