//GET text FROM SERVER
let requestText = NSMutableURLRequest(url: URL(string: "Http://a.txt")!, ...)
let sessionText = URLSession.shared
let downloadText = sessionText.dataTask(with: requestText as URLRequest) {data,response,error in
......
}
DispatchQueue.main.async {
//Update your UI here
}
}//dataTask
downloadText.resume()
//GET pic FROM SERVER
let requestText = NSMutableURLRequest(url: URL(string: "Http://a.jpg")!, ...)
let sessionPic = URLSession.shared
let downloadPic = sessionPic.dataTask(with: requestText as URLRequest) {data,response,error in
......
}
DispatchQueue.main.async {
//Update your UI here
}
}//dataTask
downloadPic.resume()
Hi, am not an expert in swift but I have a page the I would like to download pic (into UIImageView) and text (into UITextView) from a server. If I have multiple pics and text, must I run multiple session, request and Task.resume(), DispatchQueue.main.async ?
Is there way to get multiple request doing a single xxxx.resume()?
Thank you