NSBundle - (尚未加载)错误

sha*_*oga 5 nsbundle localizable.strings ios

我试图获得一个字符串文件表,用于NSLocalizedStringFromTableInBundle.

我正在使用这种方法:

+(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;
}
Run Code Online (Sandbox Code Playgroud)

虽然它在模拟器上运行良好,但当我尝试在iPhone设备上使用它时,我得到这个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)
Run Code Online (Sandbox Code Playgroud)

为什么不加载,问题出在哪里?

谢谢

沙尼

Ale*_*eem 6

检查文件路径的大小写.模拟器(默认情况下)不区分大小写,而设备是.这可能导致模拟器成功找到文件,但设备失败.