How to refer to Cocoa controls located in in the same NSWindow? -
i have nswindow nsview , nstextfield inside.
i'm using interface builder right now. have dropped 2 controls on default nswindow , subclassed nsview. i'm implementing -drawrect
method nsview , need access content of nstextfield.
how refer instance of nstextfield method inside nsview ?
your nswindow (or should be) controlled window controller. in ib create outlet nstextfield in window controller. using outlet, can refer nstextfield:
in window controller .h file:
@property (strong) iboutlet nstextfield *mytextfield;
in window controller .m file:
@synthesize mytextfield;
from there can in controller:
[[self mytextfield] seteditable: no];
a point note not access controls in window directly window windows (and cocoa controls matter) statically stored in xib/nib file. access controls (ui elements) channelled through controllers (nswindowcontroller
, nsviewcontroller
) in turn capable of loading xib/nib files.
apple provides various samples in docs on how this.
Comments
Post a Comment