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
Inject View Controller which conforms to protocol #38
Comments
Where is MyProtocol defined? Is it in its own file or is it being injected as well? Or, you could also try setting the environment variable INJECTION_DYNAMIC_CAST in your scheme. |
It's In it's own file |
unfortunately it didn't help |
Any chance of a small example project so I could look into what's going on? |
Yes |
Here is a sample project it's similar to my setup in main project |
Thanks for the example project. Injection aside, I can see that |
... Perhaps you need to do something like: if let vc = vc.instance as? TestProtocol {
vc.testPrint()
} |
Thanks! It does work in this case with vc.TestPrint() but unfortunately it won't solve problem with passing this view to side menu I have SideMenu which does problem is here
|
How do you mean "for inject to work"? If you save the file containing CalendarViewController, its methods will have been overridden for the next time they are called again. |
here is what I'm trying to do
inside menu viewControllers variable is declared like this |
It's possible the "Hosting" model Inject uses may not be for you in this instance. When you save the file containing NewsViewController it will have been "swizzled" correctly. Perhaps you just need a way to force it to redraw. Have you looked at creating an `@objc func injected()' method which should be called when the class is injected inside which you call viewDidLoad() or configure() or something to force the redraw so you can see the hot reload. |
Thanks I've overlooked this |
create an |
Maybe I will have to change SideMenu somehow to accept viewControllers |
I can zoom if you get stuck. |
wow, thanks a lot! |
Or TeamView. Send an invite/login to github at johnholdsworth.com |
Actually, TeamView if you can thanks. |
well I can see But when I change view and save nothing happens I've tried reinstalling app and installing again, installing from Mac App Store and also restarting Mac |
You seem to be watching the workspace file instead of watching the directory containing the workspace file. Use menu item "Open Project" to set it again. |
Ohhh It's working now BTW here is how I hacked thing that I can't add this view to menu directly because of protocol
|
for passing specific type only |
First Thanks for the great tool!!!
Here is my question:
I have a view controller which conforms to protocol "MyProtocol"
then I do
let calendar = Inject.ViewControllerHost(CalendarViewController())
and try to pass this calendar to the SideMenu which expects VC of MyProtocol type
but calendar returns nil, when I do calendar as? MyProtocol
are there any workarounds of this ?
The text was updated successfully, but these errors were encountered: