Avatar of varBoomer
varBoomer
 asked on

Programmatically Add UI Controls in Objective-C

I'm pretty new to Objective-C, but I do understand a lot of the syntax and the way it handles objects through messages.  But that's about it.  

One thing I'm trying to learn is how to add UI controls programmatically and I found some sample code to try and do this.  However, I'm not sure what method I need to "paste" the following code into.  It's for an NSButton.  

This is the sample code I found:
NSView *superview = [window contentView]; 
NSRect frame = NSMakeRect(10, 10, 200, 100); 
NSButton *button = [[NSButton alloc] initWithFrame:frame]; 
[button setTitle:@"Click me!"]; 
[superview addSubview:button]; 
[button release];

Open in new window


Any help is appreciated!
Swift ProgrammingProgrammingProgramming Languages-OtherObjective-C Programming

Avatar of undefined
Last Comment
pgnatyuk

8/22/2022 - Mon
varBoomer

ASKER
Wow, no response in quite some time... Either there is another forum somewhere that is specific to apple or my question just makes absolutely no sense at all...  Whatever the reason is for no response, please let me know!
ASKER CERTIFIED SOLUTION
pgnatyuk

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23