Swift- error: Variable 'self.___' used before being initialized

前端 未结 1 1910
南笙
南笙 2021-01-18 01:43

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
             


        
相关标签:
1条回答
  • 2021-01-18 01:59

    Inside let gr you are targeting self, which is an instance of class foo. Since you haven't initialised its two variables, compiler throws an error when you try to access them. Swift doesn't accept this behaviour. I suggest you to declare them as Optional.

    0 讨论(0)
提交回复
热议问题