コード内のオブジェクトにクラスを割り当てることは可能ですか? ボタンを動的に作成し、ボタンの画像をロードしています。次のようなものがあります。
myButton = [[[NSButton alloc] initWithFrame:NSMakeRect(100,100,50,25)] autorelease];
[myButton setTitle:@"Done"];
[myButton setTarget:self];
[myButton setAction:@selector(mySelector:)];
[myButton setButtonType:NSMomentaryChangeButton];
[myButton setBordered:NO];
[myButton setImage:[NSImage imageNamed:@"myButton.png"]];
[myButton setImagePosition: NSImageOnly];
[[[self window] contentView] addSubview:myButton];
ボタンに特定の動作を持たせるために使用したい NSButton サブクラス (MyButtonClass.h/MyButtonClass.m など) もありますが、上記のコードでそのクラスをボタンに割り当てる方法がわかりません。 .
これは可能ですか、それとも Interface Builder でのみ行うことができますか?