0

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?

  • Does this answer your question https://stackoverflow.com/a/60019566/12299030 or https://stackoverflow.com/a/62268560/12299030 (or same just find by keywords)? – Asperi Jan 11 '21 at 07:19
  • Adding your code to the question always makes it easier to answer. – Iiro Alhonen Jan 11 '21 at 08:23

0 Answers0