This is a very interesting problem that I have. My application had a problem with presentViewController:animated:completion:and dismissViewControllerAnimated:completion:. It happens that currentViewController is called and based on server information, it is possible that the view manager will be fired. I would get the error message βI canβt fire until itβs completely submittedβ (the animation is set to βYESβ).
I queued up the present and rejected the calls. This works just fine and I'm really happy with this solution. Then I realized another problem: what if I accidentally call Apple methods directly (I have a method called myPresentViewController:animated:completion:and myDismissViewControllerAnimated:completion:that processes the queue).
Is there a way to set up a warning method if I directly call Apple methods? I tried to create a category (I also tried the extension), defining Apple and rejecting the methods and adding an obsolete message to them. None of these methods worked. I was thinking of swizzling methods, but this does not work, because if the swizzled method adds it to the queue, how will it know when to call the apple implementation? I understand that a warning will appear in one place where I need to call the Apple method, but I can use #pragma to ban warnings for the two lines that I need.
source
share