Reputation: 131
i have a plist placed inside en.lproj. I am trying to get its path this way,
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSMutableString *localizedPath = [[NSMutableString alloc] initWithFormat:@"%@/%@.%@/%@",bundlePath,lang,@"lproj",@"1.plist"];
where 1.plist is in en.lproj/1.plist put in resources.
Does [[NSBundle mainBundle] bundlePath];
give correct path to my resources? Can any body give me any clue. I am using this for iPhone , and i am new to Mac os x development, can it be used for mac os x development as well?
-- Regards,
U'suf
Upvotes: 0
Views: 1229
Reputation:
It get the path to the resources directory, use
NSString * resourcePath = [[NSBundle mainBundle] resourcePath];
To get the path to a particular resource though use
NSString * resourcePath = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"plist"];
The above will get the resource from the localization declared by the user in their general settings.
If you want to specify the localization yourself, then try
NSString * resourcePath = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"plist" inDirectory:nil forLocalization:localization];
Upvotes: 2