Last active
April 7, 2019 21:34
-
-
Save romyilano/3f56acba2beb4b7829e3268d3ac07a4a to your computer and use it in GitHub Desktop.
retain cycle sin blocks in objective-c thru apple. //
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
// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW16 | |
@interface XYZBlockKeeper : NSObject | |
@property (copy) void (^block)(void); | |
@end | |
@implementation XYZBlockKeeper | |
- (void)configureBlock { | |
self.block = ^{ | |
[self doSomething]; // capturing a strong reference to self | |
// creates a strong reference cycle | |
}; | |
} | |
... | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment