Ios 从plist创建字典,返回null

Ios 从plist创建字典,返回null,ios,objective-c,Ios,Objective C,我的项目中有一个plist文件,如下所示: 我在做这个 NSURL *file = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"plist"]; //Lets get the file location NSDictionary *plistContent = [NSDictionary dictionaryWithContentsOfURL:file]; NSLog(@"dic::%@", pl

我的项目中有一个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);

我似乎做的每件事都会在日志中返回(null)。你知道为什么吗?

你的plist根是数组,不是字典。使用:

NSArray *plistContent = [NSArray arrayWithContentsOfURL:file];

当然,您现在有了一系列字典。您不能再简单地要求
所有密钥了。

返回的内容:NSFileManager*fileManager=[NSFileManager defaultManager];[fileManager fileExistsAtPath:[NSURL fileURLAtPath:file]]?