I want to return a NSString *
from a UIViewController, called InputUIViewController, to the previous UIViewController, called CallerUIViewController, which started InputUIViewController. I want to do it just before or when InputUIViewController calls:
[self dismissModelViewControllerAnimated:YES];
Is there a standard way to do this?
You can do this by simply creating a
NSString
object asproperty
in prvious view controller and when in second view you calldismissModelViewControllerAnimated
then before it assign value to previous view controllerproperty
. This might help you -Passing data between classes using Objective-C
The standard way to do this would be to use a delegate.
In your InputViewController add a new delegate protocal, and a property for your delegate.
Then in your CallerUIViewController implement the delegate. Then just before your dismiss the modal view controller you can call back to your delegate.
So your InputViewController might look like this:
The method that dismisses the modal view would look something like this:
Then in your CallerUIViewController you would implement the InputViewControllerDelegate and the didFinishWithInputView method.
The CallerUIViewController header would look something like:
and your didFinishWithInputView method would be implemented something like:
Just before your present the InputViewController you would set the delegate to self.