I want to programatically add several NSTextFields to a window when it loads. I call the below method for each one in the init such as:
- (id)initWithWindow:(NSWindow *)window{
[self addTextField:firstTextField toWindow:window at:20];
}
-(void)addTextField:(NSTextField*)theTextField toWindow:(NSWindow*)theWindow at:(CGFloat)y{
theTextField = [[NSTextField alloc] initWithFrame:NSMakeRect(10, y, 200, 20)];
[theTextField setBezeled:NO];
[theTextField setDrawsBackground:NO];
[theTextField setEditable:NO];
[theTextField setSelectable:YES];
[[theWindow contentView] addSubview:theTextField];
}
I don't get any errors, not even when I call the setStringValue for one of the NSTextFields. However, they are not visible in the window. Have I missed something simple, or am I trying something that is not allowed?
Thanks