Database Reference
In-Depth Information
Build and run to see your work in action. Right off the bat, each qualifying zone lists
teams by the number of wins. Tap on different countries a few times. You'll see the
cells animate smoothly to maintain this order.
For example, in the first screenshot, Switzerland leads Europe with 6 wins. Tapping
on Bosnia & Herzegovina brings
their
score to 6 and moves the cell on top of
Switzerland with a nice animation. This is the fetched results controller delegate in
action!
There is one more delegate method in
NSFetchedResultsControllerDelegate
. Add it
to the class:
func
controller(controller:
NSFetchedResultsController
,
didChangeSection sectionInfo:
NSFetchedResultsSectionInfo
,
atIndex sectionIndex:
Int
,
forChangeType type:
NSFetchedResultsChangeType
) {
let
indexSet =
NSIndexSet
(index: sectionIndex)
switch
type {
case
.Insert:
tableView
.
insertSections
(indexSet,
withRowAnimation: .
Automatic
)
case
.Delete:
tableView
.
deleteSections
(indexSet,
withRowAnimation: .
Automatic
)
default
:
break
}
}