枚举错误'member'不是“Enum”的类型

时间:2016-08-02 12:47:38

标签: ios swift

我正在使用KolodaView库:https://github.com/Yalantis/Koloda

在这个库中,delegate方法中有一个公开定义的函数:

func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) {}

SwipeResultDirection是枚举,在库中定义:

public enum SwipeResultDirection: String {
  case Left
  case Right
  ...
}

但是当我在ViewController中访问它时,它的错误是

  

'Right" is not a type of "SwipeResultDirection"

这是我的代码:

class ViewController: UIViewController {
  @IBOutlet weak var kolodaView: KolodaView!
}

extension ViewController: KolodaViewDelegate {
  func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection.Right) {
    // Error here
    return
  }
}

1 个答案:

答案 0 :(得分:0)

我不熟悉这个框架,但我认为它应该是这个:

extension ViewController: KolodaViewDelegate {
    func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) {
        if direction == .Right {
            print("Apple")
        } else if direction == .Left {
            print("Cherry")
        }
    }
}