Understanding NSFetchedResultsSectionInfo Syntax

I am studying a master data tutorial and am confused about the lines of the following code:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    id <NSFetchedResultsSectionInfo> sectionInfo = [self.fetchedResultsController sections][section];
    return [sectionInfo numberOfObjects];
}

As I know, NSFetchedResultSectionInfo is a protocol, but a protocol is a list of methods defined in the class header. I don’t understand what is going on here, what is the meaning of double square brackets [..][..];?

Perhaps this is a new modern objective-c syntax that I did not know would be nice if someone could explain this more clearly to me, thanks.

+4
source share
2 answers

id <NSFetchedResultsSectionInfo> sectionInfo means in this case that the result

[self.fetchedResultsController sections][section];

// ->

NSArray *sections = [self.fetchedResultsController sections]; // array of objects, that confirm <NSFetchedResultsSectionInfo>
// sections[section] is same as [sections objectAtIndex:section]

is a class that confirms the protocol NSFetchedResultsSectionInfo

[sectionInfo numberOfObjects]; ;)

+3

<NSFetchedResultsSectionInfo> NSFetchedResultsSectionInfo.

, NSFetchedResultsSectionInfo.

+1

All Articles