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