45 ms·
Generally you don't use reference types until you encounter a need for something to be a reference type, such as being a reference to a particular resource, or
by dwaite 3y ago
Generally you don't use reference types until you encounter a need for something to be a reference type, such as being a reference to a particular resource, or for usage compatibility with an external system.
For example, there are something like eight classes exposed in the minimal swift standard library, representing concepts like managed buffers, singletons like the MainActor, and for implementing concepts like task-local values. These are all examples of types which do not lend themselves to being value types.
Once you start getting to file and network I/O, or interfacing with Objective-C, you start to see the percentage of reference types climb.
- cageface 3y agoUnfortunately the new Observation framework in SwiftUI currently forces you to use classes to model your data. Hopefully they can find some way to make it work with value types.