Being able to specify default parameter values in Swift allows us to reduce the number of function overloads in our code. For protocols it is still possible as long as we use an extension and delegate to the version without the default values. 🎉

protocol ErrorController {
   func showError(_ error: String, delegate: ErrorViewControllerDelegate?)
}

extension  ErrorController {
   func showError(_ error: String, delegate: ErrorViewControllerDelegate? = nil) {
      showError(error, delegate: delegate)
   }
}

class ContactsViewController: UIViewController, ErrorController {
   func showError(_ error: String, delegate: ErrorViewControllerDelegate?) {
      print(error)
   }
}

let contacts: ErrorController = ContactsViewController()
contacts.showError("I don't need a delegate.")

Thanks for reading and happy coding! 🙏