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

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

How can get access to EnvironmentObject of a View in another class outside of that view in SwiftUI?

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?


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

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...