Skip to content

Commit c06abd5

Browse files
author
Luka Bratos
committed
Use strongSelf instead of self
1.) Prevent using `self` which is relying on a compiler bug: https://github.com/apple/swift-evolution/blob/master/proposals/0079-upgrade-self-from-weak-to-strong.md#relying-on-a-compiler-bug 2.) Unwrapping self by using strongSelf is used already in other places in the project so this will make the code consistent across the project.
1 parent c7c9497 commit c06abd5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Foundation/URLSession/URLSession.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,10 @@ open class URLSession : NSObject {
295295

296296
let invalidateSessionCallback = { [weak self] in
297297
//invoke the delegate method and break the delegate link
298-
guard let `self` = self, let sessionDelegate = self.delegate else { return }
299-
self.delegateQueue.addOperation {
300-
sessionDelegate.urlSession(self, didBecomeInvalidWithError: nil)
301-
self.delegate = nil
298+
guard let strongSelf = self, let sessionDelegate = strongSelf.delegate else { return }
299+
strongSelf.delegateQueue.addOperation {
300+
sessionDelegate.urlSession(strongSelf, didBecomeInvalidWithError: nil)
301+
strongSelf.delegate = nil
302302
}
303303
}
304304

0 commit comments

Comments
 (0)