我的项目中有一个plist文件,如下所示:
而我正在这样做
NSURL *file = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"plist"]; //Lets get the file location
NSDictionary *plistContent = [NSDictionary dictionaryWithContentsOfURL:file];
NSLog(@"dic::%@", plistContent);
NSArray *arrayRead = [plistContent allKeys];
NSLog(@"test::%@", arrayRead);
Run Code Online (Sandbox Code Playgroud)
我似乎做的所有事情都在我的日志中返回(null).有什么想法吗?
你的plist root是一个数组,而不是字典.使用:
NSArray *plistContent = [NSArray arrayWithContentsOfURL:file];
Run Code Online (Sandbox Code Playgroud)
当然,你现在有一系列字典.你不能简单地要求allKeys
了.
归档时间: |
|
查看次数: |
73 次 |
最近记录: |