DispatchQueue : Cannot be called with asCopy = NO on non-main thread

You should call all code from showAlertMessage on main queue: class func showAlertMessage(message:String, viewController: UIViewController) { DispatchQueue.main.async { let alertMessage = UIAlertController(title: “”, message: message, preferredStyle: .alert) let cancelAction = UIAlertAction(title: “Ok”, style: .cancel) alertMessage.addAction(cancelAction) viewController.present(alertMessage, animated: true, completion: nil) } }

Is DispatchQueue.global(qos: .userInteractive).async same as DispatchQueue.main.async

The “quality of service” definitions are described here: https://developer.apple.com/library/content/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html It looks like the “main” thread will have a QoS class of “User-interactive”. However, just because a thread is created with a QoS of “User-interactive”, does not mean that it is the “main” thread. You can observe this in the Xcode debugger. Put a breakpoint inside … Read more

How to use background thread in swift?

Swift 3.0+ A lot has been modernized in Swift 3.0. Running something on a background queue looks like this: DispatchQueue.global(qos: .userInitiated).async { print(“This is run on a background queue”) DispatchQueue.main.async { print(“This is run on the main queue, after the previous code in outer block”) } } Swift 1.2 through 2.3 let qualityOfServiceClass = QOS_CLASS_USER_INITIATED … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)