Created
July 9, 2012 16:50
-
-
Save torsten/3077554 to your computer and use it in GitHub Desktop.
Retain cylcle warnings
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
// 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