I have 2 functions with the same name but different parameters.
The first one accepts as a parameter a function that accepts 2 doubles and returns one.
The second one accepts as a parameter a function that accept 1 double and returns one. This works in Swift 1.1, tested on Xcode 6.1.1, however in Swift 1.2, tested on Xcode 6.4 (beta), this doesn't work and gives me this error:
Method 'performOperation' with Objective-C selector 'performOperation:' conflicts with previous declaration with the same Objective-C selector
What can I do that this can work, and why that is happening? I know that I can do the square root another way then it is here,but I want to know whats the problem.
Edit
@IBAction func operate(sender: UIButton) {
let operation = sender.currentTitle!
if userIsInMiddleOfTypingANumber{
enter()
}
switch operation{
case "×" : performOperation {$0 * $1}
case "÷" : performOperation {$1 / $0}
case "+" : performOperation {$0 + $1}
case "−" : performOperation {$1 - $0}
case "√" : performOperation {sqrt($0)}
default : break
}
}
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()
}
}