如何检查plist是否为空?
答案 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");
}