Sunday, 15 July 2012

objective c - For loop not removing views? -



objective c - For loop not removing views? -

i have next code:

(nsimageview *image in self.view.subviews) { if (image.frame.size.height == 67 && image.frame.size.width == 46) { [image removefromsuperview]; } }

this called when button pressed. want each nsimageview has dimensions removed. problem is, removes 1 only. have maintain clicking button on , on clear images. there 4 of them.

however, noticed log produces shows lastly line getting removed each time. i'm guessing because these images top-most layers.

so question is, how can create each nsimageviews height of 67 , width of 46 removed view @ once?

thank you!

the mutating array error should prevent code executing. utilize instead:

nsarray *copy = [self.views.subviews copy]; (nsimageview *image in copy) { if (image.frame.size.height == 67 && image.frame.size.width == 46) { [image removefromsuperview]; } }

objective-c xcode cocoa

No comments:

Post a Comment