Sorry I am new in Swift, I have a curious question about global sharing ObservableObject
I saw this answer and understand @EnvironmentObject here
https://stackoverflow.com/a/59919052/9585130
Instead using @EnvironmentObject why we don't use like this?
class Person: ObservableObject {
let shared = Person()
}
Then anywhere in view we can use like below and no need EnvironmentObject any more?
struct BookList: View {
@ObservedObject var persionViewModel = Person.shared
...
}
struct BookView: View {
@ObservedObject var persionViewModel = Person.shared
...
}
Is it impact to memory leak issue?