I have two view controllers called DataPass and ViewController. I want to pass a data from DataPass to ViewController. I have a label in ViewController and I have a UIButton in my ViewController which will dismiss itself and while dismissing will pass a data to label in DataPass.
I could not do it. Please help. Here is my code:
ViewController.h
@interface ViewController : UIViewController
- (IBAction)sayfaGec:(id)sender;
@property (retain, nonatomic) IBOutlet UILabel *label;
+(ViewController *)hop;
ViewController.m
+(ViewController *)hop{
static ViewController *myInstance = nil;
if (myInstance == nil){
myInstance = [[[self class]alloc]init];
myInstance.label.text = @"test";
}
return myInstance;
}
DataPass.h
- (IBAction)sayfaKapat:(id)sender;
DataPass.m
- (IBAction)sayfaKapat:(id)sender {
[ViewController hop].label.text = @"ddsg";
[self dismissModalViewControllerAnimated:YES];
}