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 wish to cross 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 acquired 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, after I adopted the error message and put self
, a reminiscence leak occurred. So might you inform me if I could make it weak reference.