Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS: Accessing the same instance of UIViewController that called the Segue
    primarykey
    data
    text
    <p>I have two view controllers. MainViewController pushes SignUp ViewController. Once SignUp View Controller dismisses, I need access to the same instance of MainViewController to update a UIButton.title. </p> <p>.h MainView</p> <pre><code>//MainViewController.h #import &lt;UIKit/UIKit.h&gt; @interface MainViewController : UITableViewController -(void)loggedIn; @end </code></pre> <p>.m</p> <pre><code>@interface MainViewController () @end -(void)loggedIn { NSLog (@"This is Logged in inside MainView.m"); self.logInOutButton.title = @"Logout"; } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { UIViewController *destinationViewController = segue.destinationViewController; Signup *signUp = [destinationViewController isKindOfClass:[SignUp class]] ? (Signup*)destinationViewController : nil; signUp.mainViewController = self; NSLog(@"Preapre For Segue %@", self); } </code></pre> <p>.h SignUp</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "MainViewController.h" @interface SignUp : UIViewController @property (strong, nonatomic) MainViewController *mainViewController; @end </code></pre> <p>.m</p> <pre><code>@synthesize mainViewController; - (void) loggedIn { NSLog(@" MainViewController %@", mainViewController); [mainViewController loggedIn]; self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; } </code></pre> <p>When I do NSLog I'm getting different values:</p> <pre><code>Preapre For Seg &lt;STMainViewController: 0x9f7d600&gt; MainViewController (null) </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.
 

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