[iOS-Swift编程]Method '...' with Objective-C selector '...' 错误的解决方法

来源:互联网 发布:h3c 5500 端口聚合 编辑:程序博客网 时间:2024/06/05 14:46

我的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

 

0 0
原创粉丝点击