Here’s my app design. I have mainController which presents secondViewController. Now, I want to dismiss secondViewController and subsequently call the method aMethod on mainController like so:
[self dismissViewControllerAnimated:YES completion:aMethod];
But this gives me the error use of undeclared identifier 'aMethod'
Obviously I am not using the completion handler correctly, but I cannot figure out the correct way.
I think this what you are looking for,
In the above code you need to declare
selfoutside the block and use it as,Just to avoid
selfgetting retained in block.Update:
Got the issue now. You need to declare
mainControlleras a property in your .h file ofsecondViewController. After that when you are presenting thesecondViewControllerfrommaincontroller, you need to set it as,In your
SecondViewController.hfile,In your
SecondViewController.mfile,Update 2:
If you do not want to declare
maincontrolleras a property, try this. I am not sure whether this is the right way to do. But it looks like it used to work.Update 3(Suggested):
This should work for you. Check it.