August 2011
Intermediate to advanced
552 pages
23h 48m
English
Blocks have retain counts. If you have retain counts, you can get retain cycles. Here is a typedef for a simple block, and a class that references the block, along with a string instance variable.
typedef void (^BoringBlock)(void);
// The leaky object.
@interface Leakzor : NSObject {
NSString *_string;
BoringBlock _blockhead;
}
// Print |string|.
- (void) funk;
@end // Leakzor
And here are -init and -dealloc.
- (id) init { if ((self = [super init])) { _string = @"snork"; ...Read now
Unlock full access