我在 dot-m 文件中有一个“decisionText”的标签代码,如下所示:
@synthesize decisionText ; //<<<This generates the error
在 dot-h 文件中,代码编写如下:
IBOutlet UILabel *decisionText
我得到的错误是:没有在界面中找到属性“decisionText”的声明。
ps:在界面生成器中单击标签时,我可以在与文件所有者映射的引用出口下找到名称“decisionText”
坚持这一点。:(
正如建议的那样,我删除了@synthsize decisionText 行并使用了:
@property (nonatomic,weak) IBOutlet UILabel *decisionText ;
现在我得到错误:在“弱”之前需要一个属性属性
点 M 文件:
#import "ClickButtonViewController.h"
@implementation ClickButtonViewController;
//@synthesize decisionText ;
@property (weak,nonatomic) IBOutlet UILabel *decisionText ;
-(IBAction)buttonPressed:(id)sender
{
decisionText.text = @"Go for it!" ;
}
-(void)dealloc{
[decisionText release];
[super dealloc] ;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
@end