ios - Re-initialize a lazy initialized variable in Swift -


I have a variable that has been started:

  lazy var aClient : Client = {var _aClient = Clinet (ClinetSession.shared ()) _aClient.delegate = self return _aClient} ()  

The problem is, at some point, let me reset this aClient Need to do the variable so that it can start again when changed ClinetSession.shared () but if I set the class to the optional clint? , when I try to set it to zero , LLVM will give me an error if I call it aClient = Clinet (ClinetSession.shared ()) Using the Reset elsewhere in the code, it will end with EXEC_BAD_ACCESS .

Can lazy be used and can be allowed to reset itself?

Thank you!

The idle is clearly meant to start only once the model you want to adopt is probably only Is an initial-on-demand model:

  var aClient: client {get {if (_aClient == blue) {_aClient = Client (ClientSession.shared ())} __Client back! }} Var _aClient: Client?  

Now whenever _aClient is zero , it will be launched and returned. It can be restarted by setting _aClient = nil


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -