0
func performOperation(operation: (Double, Double) -> Double){
    if operandStack.count >= 2 {
        displayValue = operation(operandStack.removeLast(), operandStack.removeLast())
        enter()
    }
}

func performOperation(operation: Double -> Double) {
    if operandStack.count >= 1 {
        displayValue = operation(operandStack.removeLast())
        enter()
    }
}

The error shown is " Method 'performOperation' with Objective-C selector 'performOperation:' conflicts with previous declaration with the same Objective-C selector " This error is shown in second function.

I want to use two functions with same name but different input types, but Xcode is showing an error. How can I correct the error?

  • To get it working you will need to change the method signature. Instead of passing just a tuple, pass the parameters individually. (This problem is due to the objc runtime compatibility layer when working with Cocoa/CocoaTouch) – JMFR Sep 01 '15 at 15:02

1 Answers1

0

Objective-C does not support method overloading. When you inherited UIViewController you inherited NSObject and made the class interopable to Obj-C. Swift on the other hand does support overloading, that's why it works when you remove the inheritance.

Arslan Asim
  • 1,232
  • 1
  • 11
  • 29