【发布时间】:2012-04-19 21:19:16
【问题描述】:
我的文件中有以下代码
NSString *filePath = [[NSBundle mainBundle]pathForResource:@"images" ofType:@"plist"];
NSArray *array = [[NSArray alloc]initWithContentsOfFile:filePath];
for (id dict in array) {
NSLog(@"This is the id: %@" ,[dict objectForKey:@"Id"]);
}
当我在调试器上运行它时,它会在 NSString *filePath 行上显示“无效 CfStringref”。
无论我尝试什么代码,我都无法通过这个。
有什么想法吗?
plist 也是一个字典数组,但我无法解析它们,因为代码不起作用
【问题讨论】:
-
支持文件?那个目录不存在。是在文档目录、库目录还是在bundle中?
-
在我们的 app 文件夹中,我们有一个名为 Supporting files 的目录。 main.m 在他们以及这个 plist 中。
-
不,在设备上,Xcode 文件夹没关系。你可以在 Xcode 中拥有数百万个文件夹,但 iOS 沙盒并没有对 Xcode 的文件结构提供任何支持。那么,这是在应用程序包中吗?
-
是的,它在设备包中
-
NSLog(@"%@", [[NSBundle mainBundle]pathForResource:@"images" ofType:@"plist"]);是返回 null 还是返回路径?
标签: ios arrays plist nsmutabledictionary cfstring