NSBundle
lastmod 2015-04-04created 2014-03-043 edits
NSBundle provides methods for locating and handling application (and tool) resources at runtime.
Supports locating resources and handling the application at runtime.
How to get the path of a resource
Use it as follows to get the path.
NSString * file_path = [[NSBundle mainBundle] pathForResource: @"FILE_NAME" ofType: @"FILE_EXT" inDirectory: @"FILE_DIR"];
For reference, FILE_NAME is the file name, FILE_EXT is the file extension, and FILE_DIR is the directory where the file is located.
Do not add a period (.) to the file extension. Add a slash (/) at the end of the directory where the file is located.
Localized String
The APIs for applying localized strings are defined in NSBundle.h as follows.
#define NSLocalizedString(key, comment) \
[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]
#define NSLocalizedStringFromTable(key, tbl, comment) \
[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:(tbl)]
#define NSLocalizedStringFromTableInBundle(key, tbl, bundle, comment) \
[bundle localizedStringForKey:(key) value:@"" table:(tbl)]
#define NSLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment) \
[bundle localizedStringForKey:(key) value:(val) table:(tbl)]