I am having several IBOutlets of UIView; several subviews within my parent view. I am trying to loop over all the subviews which are UIView. I want to loop over all subviews that have the name of their IBOutlet starting with "view_"
Can somebody help me with this? Question is I really want to access the name of the IBOutlet.
Here's my code for clarification:
@property (weak, nonatomic) IBOutlet UIView *view_player1;
@property (weak, nonatomic) IBOutlet UIView *view_player2;
@property (weak, nonatomic) IBOutlet UIView *view_referee1;
- (void)listSubviewsOfView:(UIView *)view {
// Get the subviews of the view
NSArray *subviews = [view subviews];
// Return if there are no subviews
if ([subviews count] == 0) return;
for (UIView *subview in subviews) {
NSLog(@"my subview name is: %@", subview.class); //?? is only giving my the type eg UIView, i want it to return view_player2
// List the subviews of subview
[self listSubviewsOfView:subview];
}
}
How can I actually get the name of the IBOutlet of the subview and compare it if it only starts with the word "view_"
Thanks