Created
April 11, 2016 23:44
-
-
Save martin-cotta/6b513d20800fa46544461f4b126f4af6 to your computer and use it in GitHub Desktop.
self reference inside a block, weakSelf and strongSelf
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
__weak __typeof__(self) weakSelf = self; | |
dispatch_group_async(_operationsGroup, _operationsQueue, ^{ | |
__typeof__(self) strongSelf = weakSelf; | |
[strongSelf doSomething]; | |
[strongSelf doSomethingElse]; | |
}); |
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
dispatch_async(dispatch_get_main_queue()) { [weak self] in | |
if let strongSelf = self { | |
strongSelf.doSomething() | |
strongSelf.doSomethingElse() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment