I’ve the next ObservableObject and SwiftUI view.
class ExampleState: ObservableObject {}
struct ExampleView: View {
@StateObject var state = ExampleState()
var physique: some View {
EmptyView()
}
}
And I need to move state to the view from a UIKit view.
class ExampleViewController: UIViewController {
var state = ExampleState()
func take a look at() -> some View {
ExampleView(state: state) // A compile error happens on this line
}
}
However I bought compile error on initializer calling. And the error message says “Reference to property ‘state’ in closure requires specific use of ‘self’ to make seize semantics specific”
First, I don’t perceive why that is closure.
Second, once I adopted the error message and put self
, a reminiscence leak occurred. So may you inform me if I could make it weak reference.