I have some weird issue here as somehow I am unable to pass NSString from one class to another. I deployed the same method that worked on other classes.
I am trying to pass a string from secondViewController to my firstViewController. Here's what I did.
firstViewController.h
NSString *pickUpAddressString;
@property (nonatomic, retain) NSString *pickUpAddressString;
firstViewController.m
@synthesize pickUpAddressString;
-(void) viewWillAppear:(BOOL)animated {
NSLog(@"pickUpAddressString is %@", pickUpAddressString); // why it's null here?
PickUpAddress.text = pickUpAddressString; // PickUpAddress is a UITextField
}
secondViewController.m
FirstViewController *controller = [[FirstViewController alloc]init];
controller.pickUpAddressString = selectedAddress; // here, I set the string
NSLog(@"selected address :%@\npickUpAddressString:%@", selectedAddress, controller.pickUpAddressString); // I had verified that both strings are valid.
[self.navigationController popViewControllerAnimated:YES]; // pop to firstView