I have a method that finds the parentVC of a view:
-(UIViewController *)mainViewController {
UIViewController *viewController = nil;
for (UIView *next = [self superview]; next; next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
viewController = (UIViewController *)nextResponder;
break;
}
}
return viewController;
}
I'd like to instead be able to just use parentVC
in the future, a macro I intend on making.
The only issue is, I don't know how to convert this to a macro so that I can just say something like, parentVC.view.alpha = 0.5f;
I'm assuming the macro will utilize blocks somehow so it can handle this iteration in finding the parent VC while still being able to be treated as an object? But I can't figure out how that may work.