Created
August 24, 2023 18:56
-
-
Save agiletortoise/e34b788304736137f1ffebe4c5ba7996 to your computer and use it in GitHub Desktop.
Intent Dependency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create an object to inject | |
struct AppIntentDependencyManager { | |
func hello() {} | |
// whatever methods you need.... | |
} | |
// in didFinishLaunching or similar inject your dependency like... | |
if #available(iOS 16.0, *) { | |
AppDependencyManager.shared.add(key: "AppIntentDependencyManager", dependency: AppIntentDependencyManager()) | |
} | |
// in your Intent definition, use below to get access to the injected manager | |
@Dependency(key: "AppIntentDependencyManager") var dependencyManager: AppIntentDependencyManager | |
// in `perform` or whatever in the intent, you can call | |
dependencyManager.hello() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment