I build an iPhone app and notice that there is the Analyze tool in XCode.
I have this code:
View * view = [[View alloc]initWithFrame:self.view.frame title:currentItem.name id:currentItem.idStr];
self.menuView = [[MenuView alloc]init];
self.menuView.contentView = view;
[view release];
and the View Property:
@property (retain,nonatomic) MenuView * menuView;
And when i make a Analyze on the project i get this potential leak warning.
And i want to know if it’s ok and the analyze just warn me? or i made a mistake with the code.
Edit
And if i do some thing like this :
@property (retain, nonatomic) IBOutlet UISlider *progressSlider;
.
self.progressSlider = [[[UISlider alloc]initWithFrame:CGRectMake(58, 12, 191, 23)]autorealese];
[view addSubview:self.progressSlider];
and in the dealloc:
[progressSlider realese];
This is what i sould to do too? or it’s wrong?
If you retain a property you should send it a release message in your dealloc method:
Also, you alloc/init when you assign the menuView property. The init method gives you a retain count of one. Setting the property gives you a retain count of two. You should have a matching number of releases. Your setup code should look like this: