У меня есть UIView, что когда я инициализировать уже сохранить кол 2, и я не понимаю, почему, в результате чего я не могу удалить его с removefromsuperviewСохранил графа и removeFromSuperview
ViewController.h
@property (nonatomic, retain)FinalAlgView * drawView;
ViewController.m
self.drawView =[[FinalAlgView alloc]init];
NSLog(@"the retain count 1 of drawView is %d", [self.drawView retainCount]);
//the retain count 1 of drawView is 2
[self.bookReader addSubview:self.drawView];
NSLog(@"the retain count 2 of drawView is %d", [self.drawView retainCount]);
//the retain count 2 of drawView is 3
[self.drawView release];
NSLog(@"the retain count 3 of drawView is %d", [self.drawView retainCount]);
//the retain count 3 of drawView is 2
[UIView animateWithDuration:0.2
animations:^{self.drawView.alpha = 0.0;}
completion:^(BOOL finished){ [self.drawView removeFromSuperview];
}];
//do not remove
Я не использую ARC
Вы используете ARC? –
На ваш вопрос только один ответ: http://stackoverflow.com/questions/4636146/when-to-use-retaincount/4636477#4636477 – rckoenes