2 ms·
The problem is you cannot implement a reference type without dropping to UnsafePointer or use class. But using class is so discourage nowadays people probably w
by liuliu 2y ago
The problem is you cannot implement a reference type without dropping to UnsafePointer or use class. But using class is so discourage nowadays people probably would be better served by adding an Arc / Ref type wrapper like Rust did.
- saagarjha 2y agoI don’t see why you shouldn’t use a class for this
- cageface 2y agoUse of class was strongly discouraged in the Swift world until they rolled out their new Observation framework for SwiftUI that requires using classes for modeling state and depends on two-way data binding to work. So all the arguments we've been hearing for years about the benefits of structs, immutable data, and controlled updates got tossed out the window. This was bad timing with the switch to strong concurrency checking in Swift 6 because doing strong concurrency handling in a world of reference types and two way binding is really painful.