makeWidget() vs. init(widget:): Does Swift Prefer Factory Methods or Convenience Inits?

If you’ve spent any time working across different programming languages, you’ve likely encountered two distinct design philosophies for object creation: When designing Swift APIs—whether for an app architecture or an open-source library—a common question arises: Should you write a make…() factory method or a convenience init? The short answer: Swift strongly prefers initializers. Let’s break Read more

How to use withObservationTracking to monitor an @Observable

Reposted from: https://forums.swift.org/t/how-to-use-observation-to-actually-observe-changes-to-a-property/67591/18 I thought I’d share an example of how I am currently using it. I wanted to make an object that maintains a sorted order of the main model’s objects. I used withObservationTracking to update if either the sort order local to this object is changed or if the particular Read more