首先在非ARC下:
testButton *_tempBtn = [[testButton alloc]initWithFrame:CGRectMake(0, 200, 200, 200)];
[self.view addSubview:_tempBtn];
//此时_tempBtn的引用计数为2
然后在ARC下:
testButton *_tempBtn = [[testButton alloc]initWithFrame:CGRectMake(0, 200, 200, 200)];
[self.view addSubview:_tempBtn];
//此时_tempBtn的引用计数为2
[_tempBtn addTarget:self action:@selector(CPCarPoolingFeeVC:paidSuccessfullyOrder:) forControlEvents:UIControlEventTouchUpInside];
//addTarget不会增加_tempBtn的retainCount(此时还是2),addTarget也不会增加self的引用计数
//addTarget是将target加入_tempBtn对象的NSSet(推测根据:allTarget函数)中,所以正常也不会增加_tempBtn的retainCount。
[[NSNotificationCenter defaultCenter] addObserver:_tempBtn selector:@selector(applicationLaunchedWithUrl:) name:@"asdasda" object:nil];
//addObserver不会增加_tempBtn的retainCount(此时还是2)
当self这个Controller被释放的时候会先走controller的dealloc此时_tempBtn存在,在这之后会走_tempBtn的dealloc