I have a function:
@objc func handleLongPress(data: SkelbimasModel, _ gestureRecognizer:UIGestureRecognizer){
if gestureRecognizer.state != .began{
return
}
let touchPoint:CGPoint = gestureRecognizer.location(in: self.Map)
let touchMapCoordinate:CLLocationCoordinate2D =
self.Map.convert(touchPoint, toCoordinateFrom: self.Map)
let annot:MKPointAnnotation = MKPointAnnotation()
annot.coordinate = touchMapCoordinate
self.resetTracking()
self.Map.addAnnotation(annot)
skelbimai.append(annot)
print(skelbimai)
self.Map.removeGestureRecognizer(gestureRecognizer)
Label.isHidden = true
}
My SkelbimbasModel inherits NSObject :
class SkelbimasModel: NSObject {...}
And that function is not being called :
func addLongPressGesture(){
let longPressRecogniser:UILongPressGestureRecognizer = UILongPressGestureRecognizer(target:self , action:#selector(ViewController.handleLongPress(data:_:)))
longPressRecogniser.minimumPressDuration = 0.5 //user needs to press for 1 seconds
self.Map.addGestureRecognizer(longPressRecogniser)
}
When i remove SkelbimasModel property from function like :
@objc func handleLongPress(_ gestureRecognizer:UIGestureRecognizer)
works fine. How to declare function to selector, to pass SkalbimasModel property?