I have an enum declaration.
enum OP_CODE {
case addition
case substraction
case multiplication
case division
}
And use it in a method:
func performOperation(operation: OP_CODE) {
}
We all know that how we can call this normally
self.performOperation(OP_CODE.addition)
But if I have to call it in some delegate where the integer value is not predictable, how do I call it?
For example:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.delegate.performOperation(indexPath.row)
}
Here, the compiler throws an error Int is not convertible to 'OP_CODE'. I've tried many permutations, but haven't been able to figure it out.