William LeGate
William LeGate

Reputation: 550

Get all objects in a UIView?

Is it possible to get all of the objects of a UIView that I have passed from one view controller to another (without getting them from the parent's view controller)? Something like

NSArray *objects = [myView getAllObjects];

Upvotes: 0

Views: 2622

Answers (1)

MechEthan
MechEthan

Reputation: 5703

Subviews? Yes:

NSArray *subviews = myView.subviews

Apple Doc for UIView property: subviews

If thats not what you meant, you'll have to clarify your question more...


EDIT: Some quick tips...

Remember you can do a for(UIView *subview in myView.subviews) {...} to easily iterate through them.

I really wouldn't recommend hanging onto to a pointer to that subview array (or any copies) beyond/outside of a single method.

Upvotes: 7

Related Questions