NSBundle - (尚未加载)错误 [英] NSBundle - (not loaded yet) Error

查看:1991
本文介绍了NSBundle - (尚未加载)错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取与NSLocalizedStringFromTableInBundle一起使用的字符串文件表。

I am trying to get a strings file table for use with 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;
}

虽然它在模拟器上工作得很好,但当我尝试使用它时我得到这个NSLog的iPhone设备:

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?

谢谢

Shani

推荐答案

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

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.

这篇关于NSBundle - (尚未加载)错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆