iOS Apprentice #3, p. 190 - syntax question

In setting up table view sections, am confused about the syntax of code:

let sectionInfo = fetchedResultsController.sections![section]

the sections![section] just doesn’t seem right to me. Can anyone explain this syntax to me? It is like writing object1object2…feel like there should be a period or something between the two of them.

Thanks!

There’s a fair bit separating them, but there are several 'section’s in this line, so let’s clarify them.

The results retrieved by fetchedResultsController are grouped into sections. Each section is actually represented by a type, an NSFetchedResultsSectionInfo type, which contains not just the results in the respective section, but other information as well.
fetchedResultsController.sections is an array of section info types, but it’s an optional property of the controller; the array may not exist. With the !, we’re insisting that it does exist. We’re then specifying (using the section index in the [] brackets) which of the sections in the array we want to access, and we’re calling that section info type sectionInfo.

If you want to rename some of the variables to improve readability - perhaps rename section to index - then do so.

Thanks. Just seemed weird to me but I get it now.