如何检查plist是否为空

时间:2010-08-22 11:55:10

标签: iphone xcode plist

如何检查plist是否为空?

1 个答案:

答案 0 :(得分:3)

如果你的plist是一个数组:

NSArray *array = [[NSArray alloc] initWithContentsOfFile:yourFile];
if ([array count] == 0) {
    NSLog(@"Your plist is empty");
}

或者如果你的plist是字典:

NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:yourFile];
if ([[dictionary allKeys] count] == 0) {
    NSLog(@"Your plist is empty");
}