I’m trying to pass a NSString text to a UIViewController in button “click” event in iOS. I wrote following code.
self.detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
self.detailViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:self.detailViewController animated:YES];
self.detailViewController.urlAddress = @"http://www.google.com";
I’ve already declared urlAddress property in detailViewController.
After I tested with NSLog in viewWillAppear, it shows only null values, not the urlAddress string. How can I solve it?
Note the order of methods being called:
initWithNibNameviewDidLoadviewWillAppearYour string is changed only after all three have done their work.
Change your code to: