1

As we know, the Swift language allows Function Overloading, in Objective-c the overloading is not legal.

So I test in my demo project:

import UIKit

class FuncOverLoad: NSObject {

func helloFuc (_ what:String) {

}
func helloFuc (_ what:Int) {

}


func helloFuc() -> String {

    return "one"

}
func helloFuc() -> Int {

    return 1

}
}

But, why there comes the error:

Method ‘helloFuc’ with Objective-C selector ‘helloFunc:’ conflicts with previous declaration with the same Objective-C selector

I take the picture:

enter image description here

Why comes the issue, if Swift function overloading is legal?

Unheilig
  • 15,944
  • 193
  • 67
  • 96
aircraft
  • 20,821
  • 22
  • 79
  • 154
  • 1
    That's a bad duplicate for this question. A much better one would be http://stackoverflow.com/questions/29457720/compiler-error-method-with-objective-c-selector-conflicts-with-previous-declara?s=1|6.5289 – rmaddy Dec 24 '16 at 06:03

1 Answers1

1

In your case, removing : NSObject would clear the errors.

Unheilig
  • 15,944
  • 193
  • 67
  • 96