複数のView Controllerを使用しており、デリゲートを使用して、あるView ControllerのUITextfieldを別のView Controllerのラベルにリンクしようとしています。
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITextFieldDelegate>
{
IBOutlet UITextField *txtField;
}
@end
ViewController.m
#import "ViewController.h"
#import "ViewController2nd.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
lbl.text = [NSString stringWithFormat:@"Hello, %@",txtField.text]
[txtField resignFirstResponder];
return YES;
}
@end
ViewController2nd.h
#import <UIKit/UIKit.h>
@interface ViewController2nd : UIViewController <UITextFieldDelegate> {
IBOutlet UILabel *lbl;
}
@end
ViewController2nd.m
#import "ViewController2nd.h"
@interface ViewController2nd ()
@end
@implementation ViewController2nd
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
私が得るエラーは次のとおりです。
Viewcontroller.m での宣言されていない識別子 lbl の使用
この問題を解決する方法がわかりません。いくつかのガイダンスが必要..ありがとう...