Created
December 4, 2014 18:07
-
-
Save danieleggert/c14d4c1856e2a3ff6ceb to your computer and use it in GitHub Desktop.
Tear Down for async code
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
@implementation Foo | |
{ | |
BOOL _needsTearDown; | |
} | |
- (instancetype)init; | |
{ | |
self = [super init]; | |
if (self) { | |
_needsTearDown = YES; | |
// initialization here | |
} | |
return self; | |
} | |
- (void)tearDown; | |
{ | |
if (_needsTearDown) { | |
// tear down back pointers and async code here. | |
_needsTearDown = NO; | |
} | |
} | |
- (void)dealloc | |
{ | |
if (_needsTearDown) { | |
__builtin_trap(); | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment