我有一个数组的plist包含2串看到图像:arrayWithContentsOfFile无法读取plist文件
http://imageshack.us/photo/my-images/263/myplist.png/
,并在我的viewDidLoad
我补充一点:
NSString *file = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"];
NSArray *array = [NSArray arrayWithContentsOfFile:file];
NSLog(@"array = %@", array);
但我为什么总是得到null
?感谢帮助。
UPDATE:解决的办法是,你需要手动编辑plist文件(Xcode4使用Dictionnary默认)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<array>
<string>HO</string>
<string>HI</string>
</array>
</array>
</plist>
发布你的完整代码.. – Aravindhan 2011-06-02 04:49:00
@funnyCoder你检查路径是否存在?也许在那里贴一个[[[NSFileManager defaultManager] fileExistsAtPath:file]'? – 2011-06-02 04:51:24
@Aravindhanarvi这是我的完整代码:)。 – funnyCoder 2011-06-02 04:52:40