Service Locator (ARCH9198)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key swift.quality.service-locator · Severity warning · Category quality
Flags services resolved from a container inside function bodies (container.resolve, Resolver.resolve, Container.shared.get).
Incorrect
Section titled “Incorrect”func run() { let repo = container.resolve(Repo.self)! }Correct
Section titled “Correct”init(repo: Repo) { self.repo = repo }Inject the dependency through init.