Como executar tarefas corretamente em uma thread de fundo em Swift (Grand Central Dispatch)
Olá a todos! Sou novo em Swift e desenvolvimento iOS. Estou escrevendo um aplicativo simples para baixar imagens da internet. Quando clico no botão "Baixar", a interface congela por alguns segundos até a imagem aparecer. Ouvi dizer que é necessário usar threads de fundo para não bloquear a thread principal (UI). Mas não entendo como fazer isso corretamente em Swift.\n\nAqui está meu código atual:\n\n```swift\nimport UIKit\n\nclass ViewController: UIViewController {\n @IBOutlet weak var imageView: UIImageView!\n \n @IBAction func loadImageTapped(_ sender: UIButton) {\n // Problema: este código é executado na thread principal\n let url = URL(string: "https://example.com/large-image.jpg")!\n let data = try! Data(contentsOf: url)\n imageView.image = UIImage(data: data)\n }\n}\n```