I am trying to get the class name of a UIViewController through one of its UI elements. When called in the following manner, the class method returns the correct name (eg: myViewController):
NSLog(@"Class name: %@", NSStringFromClass(self.class));
But when called like this, it only returns UIView:
UIButton *button = [[UIButton alloc] init];
[self.view addSubview:button];
NSLog(@"Class name: %@", NSStringFromClass(button.superview.class));
If I have reference to the button object, in another class for example, how could I get the actual name of its parent class?