1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| @interface AViewController () @property (nonatomic, strong) AObject *aObject; @property (nonatomic, strong) BView *bView; @end
@implementation AViewController
- (IBAction)clickButton:(id)sender { self.aObject = [[AObject alloc] init]; NSLog(@"retainCount = %ld", self.aObject.retainCount); [self.aObject release]; NSLog(@"retainCount = %ld", self.aObject.retainCount); BView *bView = [[BView alloc] init]; _bView = bView; NSLog(@"retainCount = %ld", bView.retainCount); [self.view addSubview:bView]; NSLog(@"retainCount = %ld", bView.retainCount); [bView release]; NSLog(@"retainCount = %ld", bView.retainCount); NSLog(@"clickButton"); }
- (void)dealloc { [super dealloc]; NSLog(@"AViewController dealloc"); } @end
2018-08-30 14:16:16.162771+0800 testram[6779:360385] retainCount = 2 2018-08-30 14:16:16.162931+0800 testram[6779:360385] retainCount = 1 2018-08-30 14:16:16.163164+0800 testram[6779:360385] retainCount = 1 2018-08-30 14:16:16.163423+0800 testram[6779:360385] retainCount = 2 2018-08-30 14:16:16.163524+0800 testram[6779:360385] retainCount = 1 2018-08-30 14:16:16.163622+0800 testram[6779:360385] clickButton 2018-08-30 14:16:54.180754+0800 testram[6779:360385] AViewController dealloc 2018-08-30 14:16:54.181212+0800 testram[6779:360385] BView dealloc
|