Skip to content

Instantly share code, notes, and snippets.

@romyilano
Last active April 7, 2019 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romyilano/3f56acba2beb4b7829e3268d3ac07a4a to your computer and use it in GitHub Desktop.
Save romyilano/3f56acba2beb4b7829e3268d3ac07a4a to your computer and use it in GitHub Desktop.
retain cycle sin blocks in objective-c thru apple. //
// 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