Created
January 6, 2021 17:59
-
-
Save hossamghareeb/572827f889fc68eb7d7e4b4ed990f8a8 to your computer and use it in GitHub Desktop.
Subclass then override for singletons
This file contains hidden or 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
class ViewController { | |
var manager: Singleton { | |
return Singleton.shared | |
} | |
} | |
// in unit testing target | |
class TestingViewController: ViewController { | |
override var manager: Singleton { Singleton() } | |
} | |
// Usage | |
func testViewController() { | |
let vc = TestingViewController() | |
// assert | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment