Scenario: The user taps on a button on a view controller. The view controller is the topmost (obviously) in the navigation stack. The tap invokes a utility class method call
You can try to implement a category on UIViewController
with mehtod like
- (void)presentErrorMessage;
And and inside that method you implement UIAlertController and then present it on self
. Than in your client code you will have something like:
[myViewController presentErrorMessage];
In that way you'll avoid unneccessary parametrs and warnings about view not being in window hierarchy.