tags:

views:

113

answers:

2

Hi,

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

A: 

What you want is -pathForResource:ofType:

NSResponder
Hey thanks this worked. :-)
A: 

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];
Brandon Bodnár
Hey yes i was missing the path for resources. thanks a lot :-)