Tôi muốn hiểu tại sao nếu tôi cố gắng đặt giá trị (I.e. setAlphaValue hoặc setTitle) cho một đối tượng (như NSButton) trong phương thức init không có gì xảy ra, nhưng nếu tôi gọi hàm setter trong awakeFromNib nó hoạt động chính xác.init and 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
là nút của bạn một IBOutlet? – Eimantas