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

Error in Code #70

Closed
cesarmtz93 opened this issue Sep 24, 2016 · 4 comments
Closed

Error in Code #70

cesarmtz93 opened this issue Sep 24, 2016 · 4 comments

Comments

@cesarmtz93
Copy link

Hi I´ve set up the project of a uitabcontroller and the drawer as the issue #41, but i have a view controller with a button action performing the next code

    let drawer = self.navigationController!.parent?.parent as! KYDrawerController
    drawer.setDrawerState(.opened, animated: true)

im getting this error "Could not cast value of type 'KYDrawerController.KYDrawerController' (0x1012c3b00) to 'renti.KYDrawerController' (0x100cb5db0)."

@ykyouhei
Copy link
Owner

As indicated by the error statement, self.navigationController!.parent?.parent is not a KYDrawerController type.
Please understand viewcontroller hierarchy.
https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/TheViewControllerHierarchy.html#//apple_ref/doc/uid/TP40007457-CH33-SW1

@cesarmtz93
Copy link
Author

cesarmtz93 commented Sep 24, 2016

I don't think it's about the hierarchy, because i had it this way since swift 2.2 and now that it was updated and you said in the ticket #57, that we need to set module column, now it breaks

because if I print this line self.navigationController!.parent?.parent i get Optional(KYDrawerController.KYDrawerController: 0x7fc0add0b270)

so it's module.class and the error Could not cast value of type 'KYDrawerController.KYDrawerController' to 'renti.KYDrawerController' , so it´s a casting problem between that.

@ykyouhei
Copy link
Owner

It will work without problems in this sample code.
Please check the implementation or configuration!
Sample.zip

@ykyouhei
Copy link
Owner

viewController hierarchy is wrong!!

@IBAction func buttonDidTap(_ sender: UIButton) {
        let drawer = tabBarController?.parent as! KYDrawerController
        drawer.setDrawerState(.opened, animated: true)
 }

Here is not the place to ask questions. It is the place to report the issue!!
First of all, please check the cause of the problem on their own.

https://medium.com/@methane/why-you-must-not-ask-questions-on-github-issues-51d741d83fde

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

2 participants