Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For anyone who is unclear on how to implement the accepted answer, here is a code example to more clearly explain how to "<a href="https://stackoverflow.com/questions/9832518/ios-pass-data-across-child-navigation-controller#answer-9832549">have a pointer to the navigation controller</a>." The following code passes an NSString from AAA (AAAViewController) to CCC (CCCViewController) with an identifier named "ToCCC" for the segue.</p> <p>1) Create a pointer to <code>foo</code> in <code>CCCViewController.h</code>.</p> <pre><code>// CCCViewController.h #import &lt;UIKit/UIKit.h&gt; @interface CCCViewController : UITableViewController @property (strong, nonatomic) NSString *foo; @end </code></pre> <p>2) In <code>AAAViewController.m</code>, create a pointer to CCCViewController (via the navigation controller) and then set <code>foo</code>.</p> <pre><code>// AAAViewController.m #import "AAAViewController.h" #import "CCCViewController.h" // Note the import statement for CCC. @implementation AAAViewController - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString: @"ToCCC"]) { CCCViewController *ccc = [[segue.destinationViewController viewControllers] objectAtIndex: 0]; ccc.foo = @"A string passed from AAA"; } } @end </code></pre> <p>3) Do something with <code>foo</code> in <code>CCCViewController.m</code> (e.g. log it to the console).</p> <pre><code>// CCCViewController.m #import "CCCViewController.h" @implementation CCCViewController - (void)viewDidLoad { [super viewDidLoad]; // Log foo to the console. NSLog(@"%@", _foo); } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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