I have read the guidelines for contributing and I understand:
error when try to call function from delegate
func sideMenuWillAppear(menu: UISideMenuNavigationController, animated: Bool) {
print("menu appear")
}
func sideMenuDidAppear(menu: UISideMenuNavigationController, animated: Bool) {
print("menu appear")
}
func sideMenuWillDisappear(menu: UISideMenuNavigationController, animated: Bool) {
print("menu dissappear")
}
func sideMenuDidDisappear(menu: UISideMenuNavigationController, animated: Bool) {
print("menu dissappear")
}
the Xcode 9 show this error
Method 'sideMenuWillAppear(menu:animated:)' with Objective-C selector 'sideMenuWillAppearWithMenu:animated:' conflicts with method 'sideMenuWillAppear(menu:animated:)' from superclass 'UIViewController' with the same Objective-C selector
@risalgue I don't have any issues with the example project. If your project is objective-C, you likely need to add @objc to the UISideMenuNavigationControllerDelegate for it to work.
I have the same, or at least a similar problem. I can't reproduce what exactly is leading to this problem, maybe it is a configuration problem related to Objective-C integration. I can get rid of the errors when I remove the default protocol implementation in the UIViewController extension. To be honest, to me it seems that forcing a global default implementation does not follow best practices anyways, even though it alleviates the necessity of providing such implementations oneself. Another issue is overriding those implementations in a Swift extension, which according to Apple is not recommended or supported, as can be seen here:
Extensions can add new functionality to a type, but they cannot override existing functionality.
@bompf thanks for your thorough investigation.
One of my goals with this library is to keep things as 'Swifty' as possible, or put another way, to not make concessions in order to support Objective-C.
For example, Objective-C does not allow for default values in function parameters, so multiple method signatures would need to be defined to support the same functionality in Objective-C. Additionally, optional methods in protocols are only supported in Objective-C and requires the additional declaration of @objc (which has other implications as well).
Ideally, I would like to remove all @objc references from the project entirely. This is admittedly a personal choice as Objective-C is the future of development with Apple products.
The need to override an extension seems like an unlikely scenario, but I do understand your point. Generally I find the current solution adequate but not ideal as it seems to not follow best practices. I'd rather have the extension than not so that developers don't have to adhere to all of the protocol's methods.
I'm open to other ideas if you have them.
I have the same error but couldn't solve it. Xcode 9 with Swift 4... Any suggestion?
@risalgue @bompf @palla89 can any of you provide additional insight on your project setup? I have multiple projects that range from objective-C to swift to a mix, and none of them return this error that @risalgue specified. Does this have to do with multiple inheritance?
Hello @jonkykong,
I have an Objective-C and Swift project, even though my main view controller which hosts the side menu in particular is a pure Swift class and descends directly from UIViewController. I will investigate more into why this issue exists in my project setup as soon as I find the time.
Hi, I solved this problem the 'ugly way' because of a deadline, commenting from line 17 to 23 in UISideMenuNavigationController.swift
// This makes adherance to the protocol optional:
extension UIViewController {
func sideMenuWillAppear(menu: UISideMenuNavigationController, animated: Bool) {}
func sideMenuDidAppear(menu: UISideMenuNavigationController, animated: Bool) {}
func sideMenuWillDisappear(menu: UISideMenuNavigationController, animated: Bool) {}
func sideMenuDidDisappear(menu: UISideMenuNavigationController, animated: Bool) {}
}
@palla89 any idea why you were getting these errors in the first place?
I Solved this problem to like palla89
Comenting the extension of UIViewController, because when adding extensions to my class, it conflicts with UIViewController Method
I can not override these functions either
it can be because my project is compile with swift 3.2 ?
I've converted the entire project to swift 4, so I think the issue is related to this, especially considering that I was using SideMenu without any warning or error on Swift 3.
I didn't investigate deeply about this problem ^^'