<!--
{
  "documentType" : "article",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/automatic-observation-tracking",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Automatic observation tracking"
}
-->

# Automatic observation tracking

Simplify updating views when data changes by making updates in methods that support automatic observation tracking.

## Overview

Use automatic observation tracking to update your views in response to model object changes without manually invalidating views. Mark your model classes with the <doc://com.apple.documentation/documentation/Observation/Observable> macro, then read model properties in methods like [`updateProperties()`](/documentation/UIKit/UIView/updateProperties()) or [`layoutSubviews()`](/documentation/UIKit/UIView/layoutSubviews()). UIKit tracks which properties you access and automatically calls these methods again when those properties change. This approach eliminates the need to manually call methods like [`setNeedsLayout()`](/documentation/UIKit/UIView/setNeedsLayout()) or [`setNeedsDisplay()`](/documentation/UIKit/UIView/setNeedsDisplay()) after updating model data, reducing opportunities for bugs and outdated displays.

These methods support automatic observation tracking in views, view controllers, presentation controllers, buttons, collection view cells, table view cells, and table view headers and footers. For more information, see [Updating views automatically with observation tracking in UIKit](/documentation/UIKit/updating-views-automatically-with-observation-tracking-in-uikit).

## Topics

### Observing data in views

[`func updateProperties()`](/documentation/UIKit/UIView/updateProperties())

Configures the view’s content and styling properties before layout.

[`func layoutSubviews()`](/documentation/UIKit/UIView/layoutSubviews())

Lays out subviews.

[`func updateConstraints()`](/documentation/UIKit/UIView/updateConstraints())

Updates constraints for the view.

[`func draw(CGRect)`](/documentation/UIKit/UIView/draw(_:))

Draws the view’s image within the passed-in rectangle.

### Observing data in view controllers

[`func updateProperties()`](/documentation/UIKit/UIViewController/updateProperties())

Configures the view controller’s content and styling properties.

[`func viewWillLayoutSubviews()`](/documentation/UIKit/UIViewController/viewWillLayoutSubviews())

Notifies the view controller that its view is about to lay out its subviews.

[`func viewDidLayoutSubviews()`](/documentation/UIKit/UIViewController/viewDidLayoutSubviews())

Notifies the view controller when its view finishes laying out its subviews.

[`func updateViewConstraints()`](/documentation/UIKit/UIViewController/updateViewConstraints())

Notifies the view controller when its view needs to update its constraints.

[`func updateContentUnavailableConfiguration(using: UIContentUnavailableConfigurationState)`](/documentation/UIKit/UIViewController/updateContentUnavailableConfiguration(using:))

Updates the content-unavailable configuration for the provided state.

### Observing data in presentation controllers

[`func containerViewWillLayoutSubviews()`](/documentation/UIKit/UIPresentationController/containerViewWillLayoutSubviews())

Notifies the presentation controller that layout is about to begin on the views of the container view.

[`func containerViewDidLayoutSubviews()`](/documentation/UIKit/UIPresentationController/containerViewDidLayoutSubviews())

Notifies the presentation controller when layout ends on the views of the container view.

### Observing data in buttons

[`func updateConfiguration()`](/documentation/UIKit/UIButton/updateConfiguration())

Updates the button configuration in response to a button state change.

[`var configurationUpdateHandler: UIButton.ConfigurationUpdateHandler?`](/documentation/UIKit/UIButton/configurationUpdateHandler-swift.property)

A closure that executes when the button state changes.

### Observing data in collection view cells

[`func updateConfiguration(using: UICellConfigurationState)`](/documentation/UIKit/UICollectionViewCell/updateConfiguration(using:))

Updates the cell’s configuration using the current state.

[`var configurationUpdateHandler: UICollectionViewCell.ConfigurationUpdateHandler?`](/documentation/UIKit/UICollectionViewCell/configurationUpdateHandler-7rqbu)

A block for handling updates to the cell’s configuration using the current state.

[`@property (nonatomic, copy, nullable) UICollectionViewCellConfigurationUpdateHandler configurationUpdateHandler;`](/documentation/UIKit/UICollectionViewCell/configurationUpdateHandler-ajhn)

A block for handling updates to the cell’s configuration using the current state.

### Observing data in table view cells

[`func updateConfiguration(using: UICellConfigurationState)`](/documentation/UIKit/UITableViewCell/updateConfiguration(using:))

Updates the cell’s configuration using the current state.

[`var configurationUpdateHandler: UITableViewCell.ConfigurationUpdateHandler?`](/documentation/UIKit/UITableViewCell/configurationUpdateHandler-974)

A block for handling updates to the cell’s configuration using the current state.

[`@property (nonatomic, copy, nullable) UITableViewCellConfigurationUpdateHandler configurationUpdateHandler;`](/documentation/UIKit/UITableViewCell/configurationUpdateHandler-746ya)

A block for handling updates to the cell’s configuration using the current state.

### Observing data in table header and footer views

[`func updateConfiguration(using: UIViewConfigurationState)`](/documentation/UIKit/UITableViewHeaderFooterView/updateConfiguration(using:))

Updates the view’s configuration using the current state.

[`@property (nonatomic, copy, nullable) UITableViewHeaderFooterViewConfigurationUpdateHandler configurationUpdateHandler;`](/documentation/UIKit/UITableViewHeaderFooterView/configurationUpdateHandler-3oji2)

A block for handling updates to the view’s configuration using the current state.

[`var configurationUpdateHandler: UITableViewHeaderFooterView.ConfigurationUpdateHandler?`](/documentation/UIKit/UITableViewHeaderFooterView/configurationUpdateHandler-49slo)

A block for handling updates to the view’s configuration using the current state.

### Observing data in collection view layouts

[`typealias UICollectionViewCompositionalLayoutSectionProvider`](/documentation/UIKit/UICollectionViewCompositionalLayoutSectionProvider)

A closure that creates and returns each of the layout’s sections.

[`init(sectionProvider: UICollectionViewCompositionalLayoutSectionProvider)`](/documentation/UIKit/UICollectionViewCompositionalLayout/init(sectionProvider:))

Creates a compositional layout object with a section provider to supply the layout’s sections.

[`init(sectionProvider: UICollectionViewCompositionalLayoutSectionProvider, configuration: UICollectionViewCompositionalLayoutConfiguration)`](/documentation/UIKit/UICollectionViewCompositionalLayout/init(sectionProvider:configuration:))

Creates a compositional layout object with a section provider and an additional configuration.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)