I have a UIView *buttonView filled with buttons. I need to update my list and re-populate my buttonView. I implemented:
if ([[self.buttonView.subviews objectAtIndex:i] isKindOfClass:[UIButon class]]
[[self.buttonView.subviews objectAtIndex:i] removeFromSuperview];
but it failed, it would not remove all the buttons (with my test with 8 buttons, it removed every other button :-?)
I then tried:
for(UIView *subview in self.buttonView.subviews)
{
if([subview isKindOfClass:[UIButton class]])
[subview removeFromSuperview];
}
and it worked perfectly.
Shouldn't both loops accomplish the same thing?
I'm guessing there is something I don't know about fast enumeration that would explain this?