I'm following this class on Swift and building apps.
At 43:30 in the video, the instructor teaches how to set up a UIPinchGestureRecognizer
, which takes in a function from another file in its Selector.
This is the code the instructor uses:
@IBOutlet weak var faceView: FaceView! {
didSet {
faceView.addGestureRecognizer(UIPinchGestureRecognizer(target: faceView, action: #selector(FaceView.changeScale(_:))))
updateUI()
}
}
I get 2 errors:
Expected expression in list of expressions,
and:
Expected ',' separator.
I have tried changing #selector
to Selector
with no luck.
the function changeScale
:
func changeScale(recognizer: UIPinchGestureRecognizer)
{
switch recognizer.state {
case .Changed, .Ended:
scale *= recognizer.scale //scale is the displayed image scale
recognizer.scale = 1.0
default:
break
}
If I surround the Selector
argument with quotes, the app crashes when I pinch, giving the following error:
unrecognized selector sent to instance.