The following simple steps will make you able to do this.
In the first Modal ViewController, you can declare a function like
- (void) setUpdatedValueWithValue: (NSString *) newValue
{
self.objTextField.text = newValue;
}
Declare this function on the header file too, so that we can access it from the other class.
In the second Modal ViewController
SecondViewController.h
@interface SecondViewController : UIViewController
{
id objFirstViewController;
}
@property (nonatomic, retain) id objFirstViewController;
@end
SecondViewController.m
@implementation SecondViewController
@synthesize objFirstViewController;
@end
Before you present the SecondViewController
pass the object of FirstViewController
to SecondViewController
like,
- (void) presentSecondViewController
{
SecondViewController *objSecondViewController = [[SecondViewController alloc] init];
objSecondViewController.objFirstViewController = self;
[self presentModalViewController: objSecondViewController animated: YES];
[objSecondViewController release];
objSecondViewController = nil;
}
Then, in the function you are calling to dismiss the SecondViewController
after the value edit you can do like,
- (void) finishEdit
{
if([objFirstViewController respondsToSelector: @selector(setUpdatedValueWithValue:)])
{
[objFirstViewController performSelector: @selector(setUpdatedValueWithValue:) withObject: editedTextView.text];
}
[self dismissModalViewControllerAnimated: YES];
}
Hope this helps.