NSBundle "not yet loaded" for existing path

Erik picture Erik · Oct 28, 2012 · Viewed 7.7k times · Source

I'm trying to implement a way to change language inside the application.

I think I have it all figured it out, but for some reason the folder is not laded as a bundle

I have a folder called kh.lproj

  NSString *path = [[NSBundle mainBundle] pathForResource:newLanguage ofType:@"lproj"];

  if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
    bundle = [NSBundle bundleWithPath:path];
    DLOG(@"Language: %@ from path %@ (%@)", newLanguage, path, bundle);
  }

The output of my dlog is

Language: kh from path ......../F1AA1E74-A014-4331-BD1B-D05D0E54AFF3/console.app/kh.lproj (NSBundle <......./F1AA1E74-A014-4331-BD1B-D05D0E54AFF3/console.app/kh.lproj> (not yet loaded))

On both the iPhone and in the simulator (with different paths of course).

I have checked in the .app folder and the kh.lproj folder is there. (In lower case).

Does any one have an idea of why this is happening? If i try to load a file that doesn't exist it just ignores it and don't try to load it.

EDIT

If its to any help, when I'm using loadAndReturnError:(NSError) i get the message:

NSLocalizedFailureReason=The bundle’s executable couldn’t be located., NSLocalizedDescription=The bundle “kh.lproj” couldn’t be loaded because its executable couldn’t be located., NSBundlePath=......./A65E8399-6CDB-4CAE-9074-803125E78BBA/storeconsole.app/kh.lproj

What does this error message mean

Answer

Erik picture Erik · Oct 28, 2012

Looks like I get what I want anyway when calling

[bundle localizedStringForKey:key value:NULL table:nil];