How to observe model changes in iOS 26

Issue #992

In the past, making your screen update when data changed in UIKit meant writing extra code, either with didSet, Combine or some other callbacks. Now, it’s automatic.

With the latest iOS 26 updates, UIKit can automatically watch your data for changes and update your views.

@Observable in iOS 26

In WWDC 2025, session What’s new in UIKit, Apple supports automatic observation tracking and a new UI update method for UIKit

We’ve been using @Observable in SwiftUI since iOS 17, but now UIKit can also see when it changes.

If you use this data inside special methods like viewWillLayoutSubviews(), UIKit automatically connects the data to your view. When the data changes, UIKit re-runs the method to update your screen. No extra work needed!

Image

UIKit now integrates Swift Observation at its core: in update methods like layoutSubviews, it automatically tracks any Observable you reference, wires up dependencies, and invalidates the right views —no manual setNeedsLayout required.

First, we make our data model observable by adding @Observable.

import Observation

@Observable
class Counter {
    var count: Int = 0
}

In our view controller, we use the counter’s data inside viewWillLayoutSubviews().

class CounterViewController: UIViewController {
    let counter = Counter()
    private let label = UILabel()

    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()

        label.text = "Count: \(counter.count)"
    }
    
    @objc private func incrementCounter() {
        counter.count += 1
    }
}

https://github.com/user-attachments/assets/bd2f03c7-d029-4efd-838d-c796823cb61d

Because we read counter.count inside viewWillLayoutSubviews(), UIKit now watches it. When the button is tapped and incrementCounter() changes the count, UIKit automatically calls viewWillLayoutSubviews() again to update the label. It’s that simple.

This feature is on by default in iOS 26. To use it in apps for iOS 18 and up, just add a key to your Info.plist file:

Set UIObservationTrackingEnabled to YES.

This new way of working makes your code cleaner and simpler. You write less code and have fewer bugs. It’s a huge improvement for building apps with UIKit!

updateProperties

Apple also introduced a new method called updateProperties

This method is designed specifically for changes that don’t affect the size or position of your views—things like changing text, colors, or images. It gets called right before layoutSubviews(), but it’s the perfect place to keep your non-layout code separate.

Image

Written by

I’m open source contributor, writer, speaker and product maker.

Start the conversation