Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Injection in a @IBSegueAction function #240

Closed
alphatroya opened this issue Sep 8, 2020 · 1 comment
Closed

[Question] Injection in a @IBSegueAction function #240

alphatroya opened this issue Sep 8, 2020 · 1 comment

Comments

@alphatroya
Copy link

alphatroya commented Sep 8, 2020

XCode 11 introduced @IBSegueAction as a new way for injection dependencies in VC modules. The new way suggests using new init(coder: ...) constructors. It broke up the current storyboard integration trick.

container.register(tag: "myVC") { 
      MyViewController() << not compile now as soon a new designated initializer now called
} 

Is there a way to use @Injected property wrappers or resolvingProperties callback in that case? Or maybe another workaround for using Storyboards alongside with IBSegueAction and Dip?

@alphatroya
Copy link
Author

Resolved by using stub initializer

    init?(coder: NSCoder, dependency: String) {
        self.dependency = dependency
        super.init(coder: coder)
    }

    @available(*, unavailable)
    required init(coder _: NSCoder) {
        fatalError("NSCoding not supported")
    }

    convenience init() {
        fatalError("init should not be called directly")
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant