March 2017
Intermediate to advanced
520 pages
13h 45m
English
To build a custom Operation class, perform the following steps:

class ImageDownloader: Operation {
let imgURL: URL
var downloadedImage: UIImage?
init(imageURL: URL) {
self.imgURL = imageURL
}
override func main() {
if self.isCancelled {
return
}
do{
let data = try Data(contentsOf: self.imgURL)
if self.isCancelled {
return
}
self.downloadedImage = UIImage(data: data)
}
catch{
print(error)
}
}
}
Read now
Unlock full access