我是核心数据的新手,我希望在下面的代码中提供一些帮助,我需要显示实体中的属性数量;
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
//NSUInteger attributeCount = [[[object entity] attributesByName] count];
float valueSF = 0;
for (NSManagedObject *object in [sectionInfo objects]) {
NSUInteger attributeCount = [[[object entity] attributesByName] count];
valueSF += [[object valueForKey:@"value"] floatValue];
valueSF = valueSF / attributeCount;
}
return [NSString stringWithFormat:@"[Average = %.03f] [Cases = %i]", valueSF, [[sectionInfo objects] count]];
}