I need make a web requests and I need that be sync, because my program must continous after login on webserver for example, or download data.
For start, I've a login in my viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
print(NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).last! as String)
self.waitView.startAnimating()
self.waitView.hidesWhenStopped = true
let group = DispatchGroup()
print("before")
group.enter()
OdooAuth.init(successBlock: { (success) in
print(success)
group.leave()
self.waitView.stopAnimating()
}) { (erro) in
group.leave()
self.waitView.stopAnimating()
print(erro)
}
}
print("before wait")
group.wait()
print("after wait")
}
However, this not works. The code keeping locked. I did thinked that when I call group.leave()
the code continous below group.wait()
. But this not happens and I don't know which way to do this.