Last active
February 1, 2019 13:47
-
-
Save sisoje/9f29fe20d89e1c30e0572449692bab74 to your computer and use it in GitHub Desktop.
Resource acquisition is initialization (RAII) in Swift: Example
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
class URLImageTableViewCell: UITableViewCell { | |
@IBOutlet weak var urlImageView: UIImageView! | |
var urlImageLoader: DeinitBlock? | |
// new task is created, old task cancelled automatically | |
func setImage(url: URL) { | |
urlImageLoader = urlImageView.setCachedImage(url: url) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment