Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-29-2011, 12:08 AM   #12 (permalink)
qdvictory
Registered Member
 
Join Date: May 2010
Posts: 1
qdvictory is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
The first one failed because subviews is not a property of self, which is presumably your view controller. If this was a custom UIView subclass, it would probably work.

The second failed because it isn't approaching the problem correctly. If you are making the array smaller each time, you have to work backwards. If you remove the object at index 0, then the object that was at index 1 is now at index 0. But your next pass removes the object at index 1, and so on.

I'm a little surprised that the 3rd one worked, because you can't change the size of the array when doing fast enumeration. I'm going to guess that it works here because the subviews property returns a copy of the array, so you aren't messing with the actual subview array.

Somebody posted a cool array trick here a few weeks ago. I haven't tested this code, but it should be something like this:

Code:
[[[self view] subviews] makeObjectsPerformSelector: @selector(removeFromSuperview)];
this is a good way.
qdvictory is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,597
Threads: 94,084
Posts: 402,781
Top Poster: BrianSlick (7,990)
Welcome to our newest member, aaronredmond844
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:43 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.