NSBundle – (尚未加载)错误
我想获得一个string文件表使用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; }
虽然它在模拟器上工作很好,当我尝试在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)
为什么不装载,问题在哪里?
谢谢
沙尼
检查你的文件path的情况。 模拟器(默认)不区分大小写,而设备是。 这可能会导致模拟器成功find文件,但设备失败。