Last active
July 25, 2023 18:58
-
-
Save twzurkan/ad7f5946bf9a7b92f7b43d37c884907c to your computer and use it in GitHub Desktop.
WithAndWithoutTask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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