Swift- error: Variable 'self.___' used before being initialized
问题 I am trying to work with gesture recognizers in a Playground but am having some trouble. Here is my class: class foo { var fooVarSwipe: Any var fooVarTap: Any init() { let gr = UISwipeGestureRecognizer(target: self, action: #selector(foo.bar)) let tr = UITapGestureRecognizer(target: self, action: #selector(foo.tar)) helloApple.addGestureRecognizer(gr) helloApple.addGestureRecognizer(tr) helloApple.isUserInteractionEnabled = true self.fooVarSwipe = gr self.fooVarTap = tr } @objc func tar() {