Answer the question
In order to leave comments, you need to log in
How to add image upload via uuid?
I'm trying to re-load Image instead of URL by UUID.
now the Image is in a https://leonardo.osnova.io/<uuid>
structure that accepts a uuid:
struct Image: Codable {
/// тот самый uuid котоырй хочу добавить
let uuid: UUID!
enum CodingKeys: String, CodingKey {
case uuid
}
}
private func fetchTopStories() {
APICaller.shared.getTopStories { [weak self] json in
switch json {
case .success(let result):
self?.result = result
self?.viewModels = result.compactMap({
NewsTableViewCellViewModel(
name: $0.data?.subsite?.name ?? "unknown",
author: $0.data?.author?.name ?? "No name",
title: $0.data?.title ?? "NO TITLE",
subtitle: $0.data?.blocks?.first?.data.text ?? "",
// здесь приложение крашится
imageURL: URL( string: "https://leonardo.osnova.io/ + \($0.data?.blocks?[1].data.items?.first?.image.data.uuid)" ?? "noImahe load")
// imageURL: URL(string: $0.cover?.url ?? " :( ")
)
})
DispatchQueue.main.async {
self?.tableView.reloadData()
}
case .failure(let error):
print(error)
}
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let article = result[indexPath.row]
var id = article.data?.blocks?[1].data.items?.first?.image.data.uuid!
// var myurl = URL(string: "https://leonardo.osnova.io/" + \(id!.uuidString))
guard let url = URL(string: "https://leonardo.osnova.io/ + \(id!.uuidString)") else {
return
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question