Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use a delegate. So in your ViewController B you need to create a protocol that sends data back to your ViewController A. Your ViewController A would become a delegate of ViewController B. </p> <p>If you are new to objective C, please look at <a href="https://stackoverflow.com/a/2534583/849123">What is Delegate</a>.</p> <p>Create protocol in ViewControllerB.h :</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @protocol senddataProtocol &lt;NSObject&gt; -(void)sendDataToA:(NSArray *)array; //I am thinking my data is NSArray, you can use another object for store your information. @end @interface ViewControllerB : UIViewController @property(nonatomic,assign)id delegate; </code></pre> <p>ViewControllerB.m</p> <pre><code>@synthesize delegate; -(void)viewWillDisappear:(BOOL)animated { [delegate sendDataToA:yourdata]; } </code></pre> <p>in your ViewControllerA : when you go to ViewControllerB </p> <pre><code>ViewControllerA *acontollerobject=[[ViewControllerA alloc] initWithNibName:@"ViewControllerA" bundle:nil]; acontollerobject.delegate=self; // protocol listener [self.navigationController pushViewController:acontollerobject animated:YES]; </code></pre> <p>and define your function: </p> <pre><code>-(void)sendDataToA:(NSArray *)array { // data will come here inside of ViewControllerA } </code></pre> <p>Edited :</p> <p>You can See this example : How you can Pass data back to previous viewcontroller: <a href="https://www.dropbox.com/s/002om8efpy6fout/passDataToPreviousContoller.zip" rel="noreferrer">Tutorial link</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload