I have a class subclassing UIView called BizView. and I have the following code
@property (nonatomic, retain)BizView * bizPlace;
/
@synthesize bizPlace = _bizPlace;
-(void) showBiz
{
BizView * biz = [[BizView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 30.0)];
self.bizPlace = biz;
[biz release];
self.bizPlace.delegate = self;
[self.bizPlace doStuff];
}
-(void) removeBizView
{
[self.bizPlace removeFromSuperview];
self.bizPlace = nil; //****** this does not call the dealloc of bizPlace
// [_bizPlace release]; >>>>>>this does call the dealloc
[self performSelector:@selector(showBiz) withObject:nil afterDelay:1];
}
//biz view delegates
-(void)didBizStuff:(BizView *)bView
{
[self.view addSubview:_bizPlace];
[self performSelector:@selector(removeBizView) withObject:nil afterDelay:1];
}
-(void)dealloc
{
self.bizPlace = nil;
[super dealloc];
}
Now according to the docs and various articles on the internet, setting self.bizPlace = nil should call the dealloc of bizPlace but this is not the case here. However, calling [_bizPlace release] does. What could be the reason for this?