I want to create NSTextField programmatically. I am new to Mac App Development.
Can anyone help me in this ?
Update :
I tried this code
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSView *myView = [[NSView alloc] init];
NSRect frameRect = NSMakeRect(20,20,100,140);
NSTextField *myTextField = [[NSTextField alloc] initWithFrame:frameRect];
[myView addSubview:myTextField];
}
This does nothing. Please correct me if i’m wrong anywhere.
Thank you.
It looks like you’re creating an
NSTextFieldOK, but you’re not adding it to anywhere visible in the view hierarchy. Your app probably contains one or moreNSWindowinstances; if you want a view to appear in a particular window, you should add it as a subview of that window’s content view.