I was wondering when I was learning Swift, but I found many Swift delegate methods with the same name.

func tableView (_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    <# code #>

  func tableView (_ tableView: UITableView, heightForRowAt indexPath: IndexPath)->CGFloat {

I think that these are different depending on the argument, etc., but is this mechanism unique to the delegate method? Or, this is possible even when creating and calling your own function Would you like ...?
I would be pleased if anyone could advise me.

  • Answer # 1

    You can also make your own.
    Defining the same name method with different arguments is called overloading.
    Try searching for "swift overload".
    About function overloading
    About multiple methods with the same name in a class