shannoga
shannoga

Reputation: 19869

NSBundle - (not loaded yet) Error

I am trying to get a strings file table for use with NSLocalizedStringFromTableInBundle.

I am using this method:

+(NSBundle*)getBundleForLang:(NSString*)lang{
     //get the path to the bundle
    NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"localizable" ofType:@"strings" inDirectory:nil forLocalization:lang];
    NSLog(@"bundlePath = %@",bundlePath);

    //load the bundle
    NSBundle *langBundle = [[NSBundle alloc] initWithPath:[bundlePath stringByDeletingLastPathComponent]];
    NSLog(@"langBundle = %@",langBundle);
    return langBundle;
}

While it is working great on the simulator, when i try to use it on an iPhone device i get this NSLog:

2011-12-09 00:40:14.533 MyApp[12754:707] langBundle = NSBundle 
</var/mobile/Applications/915E6BCB-EC44-4F1D-891B-EF68E2FA89C2/MyApp.app/he.lproj> 
(not yet loaded)

Why isn't it loaded and where is the problem?

Thanks

Shani

Upvotes: 9

Views: 17457

Answers (3)

Muukii
Muukii

Reputation: 146

Make sure the bundle contains a bundle identifier. If it does not, despite the path is available, the resources can't load from there.

Upvotes: 1

DawnSong
DawnSong

Reputation: 5152

It's not an error. Strings bundle, such as en.lproj, does not include executable file. When you try to [bundle loadAndReturnError:], it will fail, and loadAndReturnError:'s document will tell you why.

Upvotes: 1

Alex Deem
Alex Deem

Reputation: 4805

Check the case of your file paths. The simulator (by default) is not case sensitive, whereas the device is. This could cause the simulator to successfully find the file, but the device to fail.

Upvotes: 7

Related Questions