开发者

How to read the plist file OF MY APP on Mac OSX?

My Mac OS X app has (as all apps do) a plist file in its bundle which defines the bundle version, bundle name, etc.

I want to read this p开发者_如何学Pythonlist at runtime but I don't know how to do this! I even don't know where this file is located and cannot find it !!

Please, note that I am NOT looking for the plist file created in /Library/Preferences which is linked to the NSUserDefaults (this question is raised in other posts on stackoverflow and I perfectly know how to read this file).

I tried the following code (AG-Info.plist being the name of the plist in my bundle):

NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"AG-info.plist"];
 NSDictionary *plistDictionary = [[NSDictionary dictionaryWithContentsOfFile:path] retain];

But it doesn't work ! (it works in iOS apps)

Somebody knows how to find my bundle plist?


Simply use:

NSDictionary *dict = [[NSBundle mainBundle] infoDictionary];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜