Aynı isimde fakat farklı parametrelerle 2 fonksiyona sahibim.Swift 1.2 aynı işlev adı ve farklı parametresi ile çalışmaz
Birincisi, bir parametre olarak 2 ikişeyi kabul eden ve bir tane döndüren bir işlevi kabul eder.
İkincisi, 1'i çift kabul eden ve bir tane döndüren bir işlevi parametre olarak kabul eder.
Method 'performOperation' with Objective-C selector 'performOperation:' conflicts with previous declaration with the same Objective-C selector
Bunu yapabilirim? Bu Xcode 6.4 (beta), bu çalışma ve bana bu hata veriyor vermez üzerinde test Ancak Swift 1.2, Xcode 6.1.1 üzerinde test Swift 1.1, çalışır Çalışabilir ve neden bu oluyor? Kare kökü başka bir şekilde yapabileceğimi biliyorum, o zaman burada, ama sorunun ne olduğunu bilmek istiyorum.
Düzenleme
@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()
}
}
sonrası yöntemleri ve çizgi olduğunu –
@ WillM.It kullanıcısına yardımcı olmak için bu soru açılır. –