core data database is empty test

前端 未结 3 1045
失恋的感觉
失恋的感觉 2021-01-13 09:28

How can I test if the core data database is empty? I tried:

NSIndexPath *path1 = [NSIndexPath indexPathForRow:0 inSection:0];
NSManagedObject *managedObject          


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-13 10:05

    not perfect I admit but it works

    my code:

    id  sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:0];
        int fufu = [sectionInfo numberOfObjects];
        if(fufu!=0){DATABASE IS NOT EMPTY}else{DATABASE IS EMPTY}
    

    if someone know something more efective pls post it

提交回复
热议问题