I want to transfer data from view controller to second view controller using delegate. What mistake I am doing, why my protocol is not confirming on second view controller. Code:
"This Is my view Controller code"
ViewController.h
#import <UIKit/UIKit.h>
#import "SecondViewController.h"
@protocol ViewControllerProtocol <NSObject>
-(void)passData:(NSString*)data;
@end
@interface ViewController : UIViewController
@property id<ViewControllerProtocol>delegateVC;
@property (weak, nonatomic) IBOutlet UITextField *txtFieldVC;
- (IBAction)btnSendVC:(id)sender;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)btnSendVC:(id)sender {
[self.delegateVC passData:self.txtFieldVC.text];
[self performSegueWithIdentifier:@"next" sender:self];
}
@end//
"This is my second view Controller code"
SecondViewController.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
@interface SecondViewController : UIViewController<ViewControllerProtocol>
- (IBAction)btnSVC:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *txtFieldSVC;
@end
// SecondViewController.m
#import "SecondViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)passData:(NSString *)data {
self.txtFieldSVC.text = [NSString stringWithFormat:@"%@",data];
NSLog(@"Data Received: %@",data);
}
- (IBAction)btnSVC:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
@end
Where Iam wrong is that I am missing something...