I subclass UIView and have an NSString member named imgName;
All views added to the superview are MyCustomView;
I do this:
NSArray *arr = [view subviews];
for (int x = 0; x < [arr count]; x++)
{
MyCustomView *view = [arr objectAtIndex:x];
NSString *imgName = view.imgName; <-- Unrecognized selector
}
I really want access to that member. If I kept a different running list of subviews image names it would be problematic because I would also have to maintain their positioning in the view hierarchy (as I want the view hierarchy as is with zIndexes).
How can I get the string from [view subviews]?
You should double check that the subview is of the correct type. You can perform that check with something like this:
Odds are there is a subview that is not of your
MyCustomViewtype and when it is trying to cast and access that member, it cannot because it is not the appropriate type.EDIT:
You did mention that all of your subviews added are
MyCustomView. I personally wouldn’t trust the iOS structure to not have subview already embedded in aUIView