Created
September 26, 2013 08:03
-
-
Save krzysztofzablocki/6711189 to your computer and use it in GitHub Desktop.
Multiple weak call
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
Wrong: | |
__weak id obj; | |
dispatch_async(queue, ^() { | |
[obj doSomething]; | |
[obj doSomethingElse]; <- can turn to nil at any point, should store in strong at beggining of block | |
[obj doSomethingElse2]; | |
}); | |
Ok: | |
__weak id obj; | |
dispatch_async(queue, ^() { | |
[obj doSomethingAbstract];<- either everything or nothing will execute, no need for strong storage | |
}); | |
- (void)doSomethingAbstract | |
{ | |
[self doSomething]; | |
[self doSomethingElse]; | |
[self doSomethingElse2]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment