@toddthomas Say I have a stupid simple app with one view that shows a Thing. It has a popup menu that lists the names of different Things. When an item is selected, a new Thing is created and becomes the one displayed.
If I understand you, @State can’t be used to hold the only reference to the current Thing if I want the normal ARC lifecycle. I need some long-lived ThingMaker class instance outside of the view to hold the reference instead. Is that correct?
@toddthomas Thanks Todd. The issue I see is in between persisting long enough and leaking: the objects can last much longer than expected, because they seem to be held by SwiftUI itself after the application code is done with them, for some internal reason.
cont’d…
@toddthomas In UIKit, if an instance variable in a UIViewController is the sole reference to an object, setting it to nil will release that object. I can use the Resource Acquisition is Initialization technique to free resources in a timely manner. That seems not to be the case with SwiftUI.
I’m not arguing it’s a bug, just that it’s (to me) unexpected behavior. A leaky abstraction maybe.