swift3
Convert Data to String in Swift 3
This is an example using a completion handler: class func getFilm(filmID: Int, completion: @escaping (String) -> ()) { let url = URL(string: “https://api.kinopoisk.cf/getFilm?filmID=\(filmID)”)! URLSession.shared.dataTask(with:url) { (data, response, error) in if error != nil { print(error!) completion(“”) } else { if let returnData = String(data: data!, encoding: .utf8) { completion(returnData) } else { completion(“”) } } … Read more