সুইফটে 4.1 এবং এক্সকোড 9.4.1 এ
সমাধানটি হ'ল
DispatchQueue.main.async(execute: {
self.present(alert, animated: true)
})
এভাবে লিখলে আমিও ত্রুটি পাচ্ছি getting
let alert = UIAlertController(title: "title", message: "message", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .default, handler: { action in
})
alert.addAction(defaultAction)
present(alert, animated: true, completion: nil)
আমি একই ত্রুটি পাচ্ছি
Presenting view controllers on detached view controllers is discouraged <MyAppName.ViewController: 0x7fa95560Z070>.
সম্পূর্ণ সমাধান হয়
let alert = UIAlertController(title: "title", message: "message", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .default, handler: { action in
})
alert.addAction(defaultAction)
//Made Changes here
DispatchQueue.main.async(execute: {
self.present(alert, animated: true)
})