blob: f76c0ba048b5c8412ddda0bc0b71ab1b3d1e6ce5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
//
// ImageFetcher.swift
// tst
//
// Created by Vitaly Takmazov on 10.12.2019.
// Copyright © 2019 com.juick. All rights reserved.
//
import Foundation
import Combine
class ImageFetcher: ObservableObject {
@Published var data: Data = Data()
init(url: String) {
guard let imageUrl = URL(string: url) else {
return
}
URLSession.shared.dataTask(with: imageUrl) { (data, _, _) in
guard let data = data else { return }
DispatchQueue.main.async { [weak self] in
self?.data = data
}
}.resume()
}
}
|