kyzmitch
(Andrey Ermoshin)
1
Hello, can somebody help to understand if following is not handled case for compiler or it is inside UIKit?
I have next code inside View Controller subclass:
private let gestureRecognizer: UITapGestureRecognizer = {
let tap = UITapGestureRecognizer(target: self, action: #selector(MyViewController.handleTap(_:)))
return tap
}()
UIGestureRecognizer.init expects Any? type for target param.
This code compiles successfully, but gesture recogniser doesn't work.
And I see that self printed in console as (Function) and when I changed property type to be lazy var it printed correct address of object. As I remember we can't use self in constant properties before the class is fully initialised.
mayoff
(Rob Mayoff)
3
Your question is answered on stack overflow here:
2 Likes