0

I'm doing an asynchronous HTTP POST Task, on Completion I need to send back the result to the launcher viewcontroller.I have hooked on to the completion handler and everything works as intended. But I cannot properly declare the Return Variable due to this error

Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit

                dourltask() { isValid in 
                // do something with the returned Bool
                DispatchQueue.main.async {
                    self.spinner.isHidden=true;
                    self.spinner.stopAnimation(self) if(isValid) {
                  Error ---->     if let presenter presenting as? ViewController {
                            if(isValid) {
                                presenter.bvalue=false
                            }
                        }
                    }
Jack
  • 13,571
  • 6
  • 76
  • 98
techno
  • 6,100
  • 16
  • 86
  • 192

1 Answers1

1

Every instance of a type has an implicit property called self, which is exactly equivalent to the instance itself. You use the self property to refer to the current instance within its own instance methods.

dourltask() { isValid in 
                // do something with the returned Bool
                DispatchQueue.main.async {
                    self.spinner.isHidden=true;
                    self.spinner.stopAnimation(self) if(isValid) {
                    if let presenter = self.presenting as? ViewController {
                            if(isValid) {
                                presenter.bvalue=false
                            }
                        }
                    }
Jack
  • 13,571
  • 6
  • 76
  • 98