Sir,
- (void)viewDidLoad{
for (int i = 1; i <= 4; i++)
{
playButton=[[UIButton alloc]initWithFrame:CGRectMake(curLocX,1.0,45,kScrollObjHeight)];
[playButton setBackgroundImage:[UIImage imageNamed:@"Play.png"] forState:UIControlStateNormal];
[playButton addTarget:self action:@selector(playClicked) forControlEvents:UIControlEventTouchUpInside];
curLocX+=100;
}}
I have release the playButton in viewDidUnload and dealloc
1.I have created four buttons but I released only one time its right or wrong
2.I have released viewDidUnload and dealloc its right or wrong
Advance Thanks for your valuable suggestions
Suresh.M
yes, if an object has been allocated 4 times, it should be released by the same number of count.
btw am not sure what are you trying to do here, at the end of the loop playButton will only have reference to the last object and you are not even adding your playButton as a subview to any view. Anyways you can avoid using the alloc and user buttonWithType method, this method itself handles the alloc and release of UIButton object so you don’t have to worry about the release call.
}}