I am trying to equal the string of an UITextView from anotherViewController to the MainViewController . I mean users write something in UITextView from anotherViewController and when touch the done button the string in UITextView should equal to another string in MainViewController . How can I access UITextView ???
I did something like this but did not get any result !
#import "AnotherViewController"
@class AnotherViewController;
@interface MainViewContoller : UIViewController {
NSString *main_string;
AnotherViewController *textEntered;
}
-(void)viewDidLoad {
textEntered.TEXT = main_string
}
***TEXT is the name my UITextView on AnotherViewController .
EDITED :
@interface AnotherViewController : UIViewController {
UITextView *TEXT;
id delegate;
}
@property (nonatomic, retain) IBOutlet UITextView *TEXT;
@property (nonatomic ,retain) id delegate;
@end
@implementation AnotherViewController
@synthesize TEXT ,delegate;
- (IBAction)doneButton {
//!!! problem with compare ! the compiler got me some warning
[self dismissModalViewControllerAnimated:YES];
}
MAIN VIEW CONTROLLER
#import "AnotherViewController.h"
@class Another...;
@interface MainViewControlelr : UIViewController {
NSString *main_string;
TextViewController *textEntered;
}
- (void)viewDidLoad
{
textEntered.delegate = self;
}
- (void) compareText {
[textEntered.TEXT isEqual:main_string];
}
Set mainViewController object as the delegate of an object of anotherViewController type. And use that delegate from AnotherViewController to pass messages to MainViewController.
Inside MainViewController, when you create your AnotherViewController object do:
And in AnotherViewController, when your button action is done and you want to pass the text back, say store in a string. Then pass it to MainViewController as:
compareText with a NSString argument would be a method in your MainViewController class.
EDIT:
In your AnotherViewController.h interface, declare an ivar:
Then use @property (in .h) and @synthesize (in .m) for getter and setter.
Then do the above.