1. Obtain the info. plist details of the app.
Version: Bundle version
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
Application ID: Bundle identifier
NSString *bundleId = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
Application name: Bundle display name
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
Bundle name
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
2. Application language Localization
App localization macro
#define XLocalizedString(key, comment) [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]
Two key-value pairs in the Localizable. strings file, for example
"None" = "OK ";
"none" = "none";
Macro usage: (return NSString *)
LocalizedString ("none", "This is a comment ")
3. Get the file path and file in the package
Get app package path
NSString *path = [[NSBundle mainBundle] bundlePath];
App resource directory path
NSString *resPath = [[NSBundle mainBundle] resourcePath];
Obtain a. bundle under the Resource Directory
NSString* path = [resPath stringByAppendingPathComponent:@"a.bundle"];NSBundle *bundle = [NSBundle bundleWithPath:path];
Path of the readme.txt file of the received apppackage
NSString *path = [[NSBundle mainBundle] pathForResource:@"readme" ofType:@"txt"];
Article content from: http://www.cnblogs.com/xiaodao/archive/2012/07/03/2574703.html