Accessing property in the prepareForSegue of a UIViewController
If your view controller is embedded in a UINavigationController, segue.destinationViewController
refers to that navigation controller. This is what you could use:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"LinkedInAuth"]) { UINavigationController *navigationController = (UINavigationController *)segue.destinationViewController; LinkedInViewController *linkedInViewController = [[navigationController viewControllers] lastObject]; linkedInViewController setUrlAddress:self.authUrl]; }}
And if you have more than 1 segue that transitions to a view controller embedded in a UINavigationController, I usually add this to the beginning of prepareForSegue:sender
:
if ([segue.destinationViewController isKindOfClass:[UINavigationController subclass]]) id vc = [[(UINavigationController *)segue.destinationViewController viewControllers] lastObject]
Now vc
contains the view controller you're actually interested in, so you don't have to copy and paste the casting for every segue.
It doesn't look like you're assigning the delegate, which you need to do in order for the delegate pattern to work. Try adding vc.delegate = self
to your prepareForSegue.