I have a question regarding the MVC design in iOS application.
Suppose that I have set a UIView class with this gesture recogniser:
class CardView: UIView {
init(frame: CGRect) {
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePan(gesture:)))
self.addGestureRecognizer(panGesture!)
}
@objc func handlePan(gesture : UIPanGestureRecognizer) {
switch gesture.state {
case .began:
handleBegan(gesture)
case .changed:
handleChanged(gesture)
case .ended:
handleEnded(gesture)
sendDataToDatabase()
case .cancelled:
turnCardBackToOrigin()
default:
break
}
}
}
As you can see the target of the view gesture is the view itself.
Now suppose that in switch case .ended I want to send data to database.
Since I'm making View (CardView) talk with the model (Data), would this break the MVC designing rules? Is this code design implementation wrong according to MVC?