@RonakChaniyara, , ( , , ).
[presentViewController:alert animated:YES completion: {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if self.presentedViewController == alert {
[self.dismissViewControllerAnimated:YES completion:^{
}];
}
});
}];
Swift...
let alert = UIAlertController(title: "Please Wait", message: "…waiting…", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
present(alert, animated: true) {
DispatchQueue.main.asyncAfter(deadline: .now() + 3) { [weak self] in
guard self?.presentedViewController == alert else { return }
self?.dismiss(animated: true, completion: nil)
}
}