let session = URLSession.shared
if let url = URL(string: "https://api.thecatapi.com/v1/images/search") {
let task = session.dataTask(with: url) { (data, response, error) in
if let error = error { print("Error: \(error)") }
else if let data = data {
do {
let catPicture = try JSONDecoder().decode([Cat].self, from: data)
print("Decoded: \(catPicture)")
} catch {
print("Error: \(error)")
}
}
}
task.resume()
}
내일은 이 JSON 데이터를 가지고 기필코 이미지를 불러올 것...