【发布时间】:2015-01-25 22:25:01
【问题描述】:
我有enum 声明。
enum OP_CODE {
case addition
case substraction
case multiplication
case division
}
并在方法中使用它:
func performOperation(operation: OP_CODE) {
}
我们都知道正常怎么称呼它
self.performOperation(OP_CODE.addition)
但是如果我必须在某个整数值不可预测的委托中调用它,而不是如何调用它。
例如:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.delegate.performOperation(indexPath.row)
}
在这里,编译器抛出错误Int is not convertible to 'OP_CODE'。在这里尝试了许多排列。但无法弄清楚。
【问题讨论】: