Search code examples
swiftxcodeuinavigationcontroller

Redundant conformance with NavigationControllerDelegate


I have an error saying Redundant Conformance to Protocol UINavigationControllerDelegate

So here is my separate pieces of code.

class DelegateProfileViewController: FormViewController, MFMailComposeViewControllerDelegate, UINavigationControllerDelegate  {


class ChatViewController: JSQMessagesViewController, UIActionSheetDelegate, UIImagePickerControllerDelegate, 
 UINavigationControllerDelegate {


class EditSubGroupViewController: FormViewController, SelectUsersFromSubGroupDelegate, SelectSingleFromSubGroupDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {



extension CreateEngagementViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {


class FeedViewController: UITableViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate, UITextFieldDelegate {

You get the point. Each and everyone of these errors come up saying Redundant Conformance of BLANK to protocol UINavigationControllerDelegate.

I would love if someone would tell me why these errors are screwing over my project. Thanks


Solution

  • You'll get that error message if a subclass declares conformance to a protocol which is already inherited from a superclass

    Taking an example: if in your case FormViewController has already conformed to UINavigationControllerDelegate

    class FormViewController: UINavigationControllerDelegate
    

    then there is no need to conform to it again by doing this:-

    class DelegateProfileViewController: FormViewController, MFMailComposeViewControllerDelegate, UINavigationControllerDelegate
    

    Instead it should be changed to :-

    class DelegateProfileViewController: FormViewController, MFMailComposeViewControllerDelegate
    

    This will remove your redundant conformance. Hope you get an idea of what I'm talking about.