How do you share the same instance of an object between SwiftUI views without injecting it through all their common ancestors in the view hierarchy?

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Injecting Dependencies with @EnvironmentObject

  • Gio Lodi

摘要

How do you share the same instance of an object between SwiftUI views without injecting it through all their common ancestors in the view hierarchy?