---
title: "controller(_:didChange:atSectionIndex:for:)"
framework: coredata
role: symbol
role_heading: Instance Method
path: "coredata/nsfetchedresultscontrollerdelegate/controller(_:didchange:atsectionindex:for:)"
---

# controller(_:didChange:atSectionIndex:for:)

Notifies the receiver of the addition or removal of a section.

## Declaration

```swift
optional func controller(_ controller: NSFetchedResultsController<any NSFetchRequestResult>, didChange sectionInfo: any NSFetchedResultsSectionInfo, atSectionIndex sectionIndex: Int, for type: NSFetchedResultsChangeType)
```

## Parameters

- `controller`: The fetched results controller that sent the message.
- `sectionInfo`: The section that changed.
- `sectionIndex`: The index of the changed section.
- `type`: The type of change (insert or delete). Valid values are doc://com.apple.coredata/documentation/CoreData/NSFetchedResultsChangeType/insert and doc://com.apple.coredata/documentation/CoreData/NSFetchedResultsChangeType/delete.

## Discussion

Discussion The fetched results controller reports changes to its section before changes to the fetched result objects. Special Considerations This method may be invoked many times during an update event (for example, if you are importing data on a background thread and adding them to the context in a batch). You should consider carefully whether you want to update the table view on receipt of each message.

## See Also

### Responding to Changes

- [controller(_:didChangeContentWith:)](coredata/nsfetchedresultscontrollerdelegate/controller(_:didchangecontentwith:)-4kezq.md)
- [controller(_:didChangeContentWith:)](coredata/nsfetchedresultscontrollerdelegate/controller(_:didchangecontentwith:)-5ullb.md)
- [controllerWillChangeContent(_:)](coredata/nsfetchedresultscontrollerdelegate/controllerwillchangecontent(_:).md)
- [controller(_:didChange:at:for:newIndexPath:)](coredata/nsfetchedresultscontrollerdelegate/controller(_:didchange:at:for:newindexpath:).md)
- [controllerDidChangeContent(_:)](coredata/nsfetchedresultscontrollerdelegate/controllerdidchangecontent(_:).md)
