Take it in the .h file in the ParentViewController
NSString *strABC;
Make function below in ParentViewController
-(void)setString:(NSString *)strEntered{ strABC=strEntered; }
Now in the Post Post view controller do the following:
ParentViewController *objSecond = [[ParentViewController] initwithNibName:@"parentView.xib" bundle:nil]; [objSecond setString:@"Comment Controller"]; [self.navigationController pushViewController:objSecond animated:YES]; [objSecond release];
Now, in the secondViewController viewWillAppear method, write this.
-(void)viewWillAppear:(BOOL)animated{ lblUserInput.text = strABC; }
Please check spelling errors as I wrote this. Hope this help.
If you are not using a UINavigationContoller , you can do something like this.
SecondViewControler *objSecond = [[SecondViewController] initwithNibName:@"secondview.xib" bundle:nil]; [objSecond setUserInput:txtUserInput.text]; [objSecond viewWillAppear:YES]; [self.view addSubview:objSecond]; [objSecond release];
source share