我想知道爲什麼如果我嘗試在init方法中設置對象(如NSButton)的值(即,setAlphaValue或setTitle)什麼都沒有發生,但是如果我在awakeFromNib中調用setter函數,它會正常工作。init和awakeFromNib
@interface appController : NSObject {
NSButton *btn;
}
@end;
@implementation appController
-(void)awakeFromNib {
//it works
[btn setTitle:@"My title"];
}
-(id)init {
self = [super init];
if(self){
//it doesn't works
[btn setTitle:@"My title"];
}
}
@end
是您的按鈕IBOutlet? – Eimantas