Skip to content

Instantly share code, notes, and snippets.

@twzurkan
Last active July 25, 2023 18:58
Show Gist options
  • Save twzurkan/ad7f5946bf9a7b92f7b43d37c884907c to your computer and use it in GitHub Desktop.
Save twzurkan/ad7f5946bf9a7b92f7b43d37c884907c to your computer and use it in GitHub Desktop.
WithAndWithoutTask
self.photo.clipsToBounds = true
if let img = employee.photoUrlSmall {
ImageLoader.getEmployeeImage(img: img) { [weak self] data, err in
if let data = data {
DispatchQueue.main.async {
self?.photo.image = UIImage(data: data)
}
}
else {
DispatchQueue.main.async {
self?.photo.image = UIImage(named: "photo")
}
}
}
}
else {
self.photo.image = UIImage(named: "photo")
}
self.photo.clipsToBounds = true
if let name = employee.photoUrlSmall {
Task { [weak self] in
do {
let img = try await ImageLoader.getEmployeeImage(img: name)
self?.photo.image = UIImage(data: img)
}
catch {
NSLog(error.localizedDescription)
self?.photo.image = UIImage(named: "photo")
}
}
}
else {
self.photo.image = UIImage(named: "photo")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment