Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Retain cylcle warnings
// Illustrates that not all causes of retain cycles are detected by clang. Compile with:
// clang -fobjc-arc -Wall -framework Foundation test-cycle-warnings.m && ./a.out
#import <Foundation/Foundation.h>
@interface Foo : NSObject
typedef void (^Block)();
@property (readwrite, copy) Block asd;
@end
@implementation Foo
@synthesize asd = _asd;
@end
int main (int argc, char const *argv[])
{
Foo *self = [[Foo alloc] init];
self.asd = ^()
{
// Causes no retain cycle warning: (FAIL)
Block b = self.asd;
// Causes a retain cycle warning:
[self description];
};
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.