plist文件中的根项类型?

时间:2014-10-17 03:58:34

标签: objective-c cocoa plist

如何检查plist的根项是数组还是字典? 谢谢你的帮助

enter image description here

1 个答案:

答案 0 :(得分:1)

使用以下方法,您可以通过objective-C

检测字典的根元素是否为数组
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"YourCustom" ofType:@"plist"];
NSURL *theUrl = [NSURL fileURLWithPath:thePath];

id messagesInfo = [[NSDictionary dictionary] initWithContentsOfURL:theUrl];
if([messagesInfo isKindOfClass:NSDictionary]){
    NSLog(@"DictionaryFound");
}
else{
  NSLog(@"Array Found");
}