"instance member cannot be used on type" error on Swift 4 with nested classes -


i have class nested class. i'm trying access variables of outer class within nested class:

class thing{     var name : string?     var t = thong()      class thong{         func printme(){             print(name) // error: instance member 'name' cannot used on type 'thing'         }     }  } 

this however, gives me following error:

instance member 'name' cannot used on type 'thing'

is there elegant way circumvent this? hoping nested classes capture lexical scope, closures do.

thanks

you this

class thing{     var name : string = "hello world"     var t = thong()      init() {         t.thing = self         t.printme()     }       class thong{         weak var thing: thing!          func printme(){             print(thing.name)         }     }  } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -