I try to run independent multiple if statement inside @IBAction func. But I would like to finish 1st if-statement first (i put a alert block to pause the process) then run 2nd if-statement and then run the rest script. My Code is look like this:
@IBAction func onDone(_ sender: Any) {
if var1.count > 0 {
let block: DTAlertViewButtonClickedBlock = {(alertView, buttonIndex, cancelButtonIndex) in
//Do somethings
}
DTAlertView(block: block, title: "Do somethings?", cancelButtonTitle: "Cancel", positiveButtonTitle: "Let's do it!").show()
}
if var2.count > 0 {
//Do another things
}
_ = navigationController?.popViewController(animated: true)
}
But Xcode seem to run 1st if-statement and 2nd if-statement in the popViewController in the same time doesn't wait me finish the Alert Block.
Any one face the same problem? What should I put in the code or does my code has something incorrect?
You need to move the 2nd
if
inside the alter button handler.