2008 03 29Outlets from a Javascript standpoint
In Javascript, you use
document.getElementById('myObject')
to get an object and change its visibility, style, … in fact, getElementById
gets a pointer to the object you see on the page. Outlets are just like that : in your ObjC class, you use IBOutlet
to define pointers to your interface objects. You don't have to call any getElementById
as they will be automatically populated upon NIB loading.
@interface ApplicationController : NSObject { // Define an outlet to a textfield IBOutlet NSTextField* textfield; }
To connect your textfield
variable, right-drag from your instance to the interface element you want a pointer to. After the NIB is loaded, you will then be able to interact with it, like change its value with [textfield setStringValue:@"set by code"]];
.
Objective-C from Javascript
- KVC and KVO from a Javascript standpoint
- ObjC protocols from a Javascript standpoint
- Delegates from a Javascript standpoint
- Target+action from a Javascript standpoint
- Outlets from a Javascript standpoint
- Dynamic method over* from a Javascript standpoint
- The Responder Chain from a Javascript standpoint
- PerformSelector from a Javascript standpoint
- NIBs from a Javascript standpoint
- Events from a Javascript standpoint