Когда я пытаюсь скомпилировать это, я получаю эту ошибку. Что мне нужно добавить для объявления свойства в интерфейсе? Если textBox является переменной экземпляра, зачем его нужно объявлять как свойство?Реализация свойств должна иметь декларацию в интерфейсе
ViewController.h
#import <UIKit/UIKit.h>
@interface TNRViewController : UIViewController {
IBOutlet UITextField *textBox;
IBOutlet UILabel *label;
}
- (IBAction)button:(id)sender;
@end
ViewController.m
#import "TNRViewController.h"
@implementation TNRViewController
@synthesize textBox;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)dealloc {
[textBox release];
[label release];
[super dealloc];
}
- (IBAction)button:(id)sender {
NSString *Name = textBox.text;
NSString *Output = Nil;
Output = [[NSString alloc] initWithFormat:@"%@ says: Hello World!", Name];
label.text = Output;
[Output release];
}
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
[textBox resignFirstResponder];
return YES;
}
@end
Спасибо за объяснение. Он работал после удаления строки @synthesize. – pdenlinger