I defined a protocol with a method to return a tuple:
protocol SMCalculatorDelegate { func numbersToAdd() -> (Int, Int) }
When I try to call this against the delegate method in my class as follows:
class SMCalculator: NSObject { var delegate : SMCalculatorDelegate? func add() { let myTuple : (n1: Int, n2: Int) = delegate?.numbersToAdd() } }
I get the following error on a line starting let myTuple... , referring to the .numbersToAdd() section of this line of code.
"Value of optional type '(Int, Int)?' not unwrapped; did you mean to use '!' or '?'?"
Why does this not work when I can retrieve a tuple without errors?
let tuple = delegate?.numbersToAdd() println(tuple)
source share