Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

macos

plist

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 plist 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?

like image 436
Regis_AG Avatar asked Feb 25 '23 01:02

Regis_AG


1 Answers

Simply use:

NSDictionary *dict = [[NSBundle mainBundle] infoDictionary];
like image 179
Anne Avatar answered Feb 26 '23 14:02

Anne