Initialize class-instance and access variables in Swift

后端 未结 2 1541
借酒劲吻你
借酒劲吻你 2020-12-07 03:50

I just created a class and gave it some vars. Unfortunately I can\'t access these variables in my iOS-Projects. However, the same syntax works in playground...<

2条回答
  •  爱一瞬间的悲伤
    2020-12-07 04:26

    The syntax for a class declaration is:

    class : ,  {
      
    }
    

    Your declaration of ViewController includes rex.age = 2 which itself is not a declaration, it is a statement - specifically a binary expression with an infix operator.

提交回复
热议问题