Last active
February 1, 2019 13:43
-
-
Save sisoje/195e698e04ab3491f67c5b60189ededf to your computer and use it in GitHub Desktop.
Resource acquisition is initialization (RAII) in Swift: Example
This file contains hidden or 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
extension URLSessionDataTask { | |
var cancellation: DeinitBlock { | |
return DeinitBlock { [weak self] in | |
self?.cancel() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment