Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using @EnvironmentObject in my SwiftUI project, I need to get access to the var of @EnvironmentObject a View in an another class outside of that View, how can I do this?

I do not what make a new Object of used model of @EnvironmentObject, I want get access to the same Object, as like View but inside another class.

update: the main Goal of @EnvironmentObject is making our class be accessible in all Views of SwiftUI, but I see a big problem, that I cannot access to this @EnvironmentObject inside a random class, is there some code that I am missing for this goal?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
293 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...