Lazy var giving 'Instance member can not be used on type' error

后端 未结 2 1353
情话喂你
情话喂你 2020-12-16 11:57

I had this error several times now and I resorted to different workarounds, but I\'m really curious why it happens. Basic scenario is following:

class SomeCl         


        
2条回答
  •  执念已碎
    2020-12-16 12:49

    Try that :

    class SomeClass {
      var coreDataStuff = CoreDataStuff!
      lazy var somethingElse: SomethingElse = SomethingElse(coreDataStuff: self.coreDataStuff)
    }
    

    It is important to precise the type of your lazy var and to add self. to the argument you pass

提交回复
热议问题