Swift : Redundant conformance of Viewcontroller to protocol UIGestureRecognizerDelegate

marrioa picture marrioa · Sep 12, 2015 · Viewed 13.5k times · Source

I want to add two frameworks SWRevealViewController and SLKTextViewController but I get this weird error.

I read about this error but it seems confusing.

Redundant conformance of Viewcontroller to protocol UIGestureRecognizerDelegate

class Viewcontroller: SLKTextViewController,SWRevealViewControllerDelegate,UIGestureRecognizerDelegate {

    // a lot of functions and code

}

Answer

luk2302 picture luk2302 · Sep 12, 2015

The reason for the error is that you try to conform to the UIGestureRecognizerDelegate two times. One time explictily be writing it in the beginning and the second time by extending SLKTextViewController which already conforms to it - the source code of SLKTextViewController consists of the following line:

NS_CLASS_AVAILABLE_IOS(7_0) @interface SLKTextViewController : UIViewController <UITextViewDelegate, UITableViewDelegate, UITableViewDataSource, UICollectionViewDelegate, UICollectionViewDataSource, UIGestureRecognizerDelegate, UIAlertViewDelegate>

which among other protocols already lists the UIGestureRecognizerDelegate!

Solution: remove the UIGestureRecognizerDelegate by changing your code to

class Viewcontroller : SLKTextViewController, SWRevealViewControllerDelegate {