Shall I use ViewModels?

Asked on 06/11/2025

1 search

Using ViewModels can be beneficial for optimizing SwiftUI performance, especially when you want to make your views' data dependencies more granular. In the session Optimize SwiftUI performance with Instruments, it is demonstrated how creating an observable ViewModel for each view can help reduce unnecessary view body updates. By having each view depend directly on its own ViewModel rather than a larger data structure, you can ensure that only the necessary views are updated when data changes. This approach can help keep your app running smoothly by minimizing the number of updates and improving performance.