开发者

how to get the path of a localized plist under mac os x

开发者 https://www.devze.com 2022-12-23 22:13 出处:网络
i have a plist placed inside en.lproj. I am trying to get its path this way, NSString *bundlePath = [[NSBundle mainBundle] bundlePath];

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


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];


What you want is -pathForResource:ofType:

0

精彩评论

暂无评论...
验证码 换一张
取 消