Skip to content

Instantly share code, notes, and snippets.

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;
@implementation Foo
@synthesize asd = _asd;
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