Bright Future Bright Future - 4 months ago 15
iOS Question

Enum error 'member" is not a type of "Enum"

I'm using

KolodaView
library: https://github.com/Yalantis/Koloda

In this library, there's a publicly defined function in its
delegate
method:

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


The
SwipeResultDirection
is a enum, which is defined in the library:

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


But when I access it in my
ViewController
, it has the error of 'Right" is not a type of "SwipeResultDirection"

Here's my code:

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
}
}

Answer

I'm not familiar with this framework, but I think it should be some of this:

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