I hope to access all gui components on a window using tag.
But I found that some components are in the subview of the window, so
NSButton *aButton=(NSButton*)[self.window.contentView viewWithTag:tag];
will return 0x0, I have to change super view of the button from ‘self.window.contentView’ to the subview that includes the NSButton
Is there general way to access all gui objects on a window using tag, it will recognize and set the correct super view of each gui component when I use
NSObject *a=(NSObject*)[recognizedSuperView viewWithTag:tag];
to access them?
viewWithTag:only returns direct subviews that have a tag set. If you want to navigate the view hierarchy, then you should implement a recursive method to do so, but be aware that you could find the same tag value in many possible locations in the tree.