Hi guys, I'm new to objective-c and at the moment developing a small application.
I have some memory management issues and want to ask this particular question. I have a button, appearance of which I'm changing:
for (UIView *subview in button.subviews)
{
if (![subview isKindOfClass:[UIImageView class]]) // don't remove UIImageView, otherwise it will not be able to set background
{
[subview removeFromSuperview];
}
}
[button setBackgroundImage: [[imageArray objectAtIndex:itemNumber] forState:UIControlStateNormal];
/*
creating myView and myLabel here
*/
[button addSubview:myView];
[button addSubview:myLabel];
[myLabel release];
[myView release];
The code actually more complex, but there are no any leaks. Despite of this the number of allocated objects and used memory keep growing every time I do it. How can I solve this problem?
Thank you very much