天天看點

[iOS-Swift程式設計]Method '...' with Objective-C selector '...' 錯誤的解決方法

我的Xcode版本是Version 6.4 (6E35b)

描述(寫了2個一樣的func):    

    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()

        }

報錯資訊如下:

Method 'performOperation' with Objective-C selector 'performOperation:' conflicts with previous declaration with the same Objective-C selector

解決方法:

1. 對第二個performOperation進行改名;

2. 在第二個performOperation的定義前添加privtate