Whenever I want to get data from a plist file I use the following code:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"FILE_NAME" ofType:@"plist"];
NSDictionary *plistData = [NSDictionary dictionaryWithContentsOfFile:filePath];
But now I'm trying to read in data from the Info plist, and filePath is nil. Is there a different way to get data from the Info plist?
plist - The primary property list for Mac OS X applications, located in the /Contents/ directory of an . APP bundle. To view this file, right-click an application file, select "Show Package Contents," and open the Contents folder.
The Info. plist file contains critical information about the configuration of an iOS mobile app—such as iOS versions that are supported and device compatibility—which the operating system uses to interact with the app. This file is automatically created when the mobile app is compiled.
You can see the XML version of the plist by opening the file in a text editor such as Sublime Text or Atom. *Edit - you can also right click the Info.
From an earlier SO answer of mine. Attributes from the info.plist for your project are directly accessible by the following...
[[NSBundle mainBundle] objectForInfoDictionaryKey:key_name];
Your filePath is nil simply because it can't find the file - check spellings & check if the file you are trying to read from is actually in the bundle etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With