≈ the.bay.news

Attempting to use Dependency injection

Swift Forums
Attempting to use Dependency injection
Hi, I have a class called Box that I use in production. The initializer takes in no arguments. However for some SwiftUI previews / test cases I would like that class to be initialized with some values. I don't want that initializer (with values) to be available in production, it would be only used in SwiftUI previews and test cases. My attempt: I used #if DEBUG it solves my problem with minimal code change but not sure if I was missing a better way. Given below is a simplified example. @O...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.