开发者

Subclass Programmatically Added NSButton?

开发者 https://www.devze.com 2023-03-21 17:50 出处:网络
I have a bunch of programmatically created NSButtons in my app. How can I go about setting the subclass of these NSButtons without us开发者_C百科ing Interface Builder?When you create the button, don\'

I have a bunch of programmatically created NSButtons in my app. How can I go about setting the subclass of these NSButtons without us开发者_C百科ing Interface Builder?


When you create the button, don't create them as NSButtons, create them as your subclass. For example, if you had a subclass of NSButton called MyButton, instead of something like:

NSButton *button = [[NSButton alloc] initWithFrame:frame];

You would have something like:

MyButton *button = [[MyButton alloc] initWithFrame:frame];

This way button will be an instance of MyButton.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号