Hi there!
I am a novice to Swift and Xcode, but know C++.
I tried to mimick the code in a Stanford University course for iOS 8 App development (2014-15) using Xcode 7 and swift 2 for the calculator example.
In his lecture 2 video on https://www.youtube.com/watch?v=QLJtT7eSykg,the lecturer suggested over loading a function like this (and I think they were using Xcode 6 and an earlier Swift standard):
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()
}
}
However, the compiler seems to have problem with this overloading attempt, and the error is:
/Users/.../Calculator/ViewController.swift:50:10: Method 'performOperation' with Objective-C selector 'performOperation:' conflicts with previous declaration with the same Objective-C selector
The error seems to be only on the function's second definition line (indicated by forward slashes). The rest of the code has no problem.
How can I work around this error?
Thanks in advance ... moodamultani