2010-03-22 107 views
0

我在en.lproj中放置了plist。我想获得它的路径这样,如何在mac os下获得本地化plist的路径x

NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; 
NSMutableString *localizedPath = [[NSMutableString alloc] initWithFormat:@"%@/%@.%@/%@",bundlePath,lang,@"lproj",@"1.plist"]; 

其中1.plist是en.lproj/1.plist投入资源。

是否[[NSBundle mainBundle] bundlePath];给我的资源的正确路径?任何机构都可以给我任何线索。我在iPhone上使用它,我是Mac OS X开发新手,可以用于Mac OS X开发吗?

- 问候,

U'suf

回答

0

你想要的是-pathForResource:ofType:

+0

嘿感谢这个工作。 :-) – user272312 2010-03-22 04:47:21

2

它获取路径的资源目录,使用

NSString * resourcePath = [[NSBundle mainBundle] resourcePath]; 

为了获取路径到特定的资源虽然使用

NSString * resourcePath = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"plist"]; 

以上将从用户在其常规设置中声明的本地化中获取资源。

如果要指定自己的定位,然后尝试

NSString * resourcePath = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"plist" inDirectory:nil forLocalization:localization]; 
+0

嘿,是的,我错过了资源的路径。非常感谢 :-) – user272312 2010-03-22 04:47:46

相关问题