toto_tata
toto_tata

Reputation: 15402

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

Upvotes: 4

Views: 2035

Answers (1)

Anne
Anne

Reputation: 27073

Simply use:

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

Upvotes: 8

Related Questions