Skip to content

Commit

Permalink
Merge pull request #1 from samwarfield/samwarfield-patch-strongSelf
Browse files Browse the repository at this point in the history
Change `guard let strongSelf` to `guard let self`
  • Loading branch information
samwarfield authored Jan 28, 2019
2 parents 5f238fd + d5c68f3 commit b388a76
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,16 @@ let lastName = name.lastName
* **3.1.6** Be careful when calling `self` directly from an escaping closure as this can cause a retain cycle - use a [capture list](https://developer.apple.com/library/ios/documentation/swift/conceptual/Swift_Programming_Language/Closures.html#//apple_ref/doc/uid/TP40014097-CH11-XID_163) when this might be the case:

```swift
myFunctionWithEscapingClosure() { [weak self] (error) -> Void in
// you can do this

self?.doSomething()

// or you can do this
myFunctionWithEscapingClosure() { [weak self] in
// PREFERRED
guard let self = self else {
debugPrint("What happened? You lost self...")
return
}

self.doSomething()

// NOT PREFERRED
guard let strongSelf = self else {
return
}
Expand Down

0 comments on commit b388a76

Please sign in to comment.