确定NSFetchedResultsController是否为Empty

Kev*_*tre 1 iphone cocoa-touch objective-c ios

确定NSFetchedResultsController是否为空(不包含条目)的好方法是什么?我意识到可以使用fetchedObjects这会将所有结果加载到内存中吗?

DVG*_*DVG 7

fetchedObjects是一个数组,并且检查0条记录是一种很好的方式.

你也可以用

id <NSFetchedResultsSectionInfo> sectionInfo = [[_fetchedResultsController sections] objectAtIndex:section];
if([sectionInfo numberOfObjects] == 0)
{
  // do something
}
Run Code Online (Sandbox Code Playgroud)