In most Cocoa projects, using the underbar as the prefix for the instance variable is not an IBOutlet and does not use the prefix for the instance variables of IBOutlet .
The reason I don't use substructures for IBOutlet instance variables is because when you load the nib file, if you have a setter method for the plugged socket, this setter will be called. However, this mechanism does not use key encoding; therefore, an IBOutlet whose name has a prefix with a lower bar (for example, _myField ) will not be set if the installer is not named exactly like the output (for example, set_myField: , it is standard and rude.
Also, keep in mind that using properties like self.myProp does not match access to instance variables. You send a message when using the property, as if you used parenthesized notation, for example [self myProp] . All properties give you a brief syntax for specifying both getter and setter on one line and allow you to synthesize their implementation; they do not actually close the message sending mechanism. If you want to access the instance variable directly, but prefix with self , you need to consider self as a pointer, for example self->myProp , which is really access to the C-style field.
Finally, never use Hungarian notation when writing Cocoa code and avoid other prefixes such as "f" and "m_" - this will mean that the code was written by someone who does not "receive it" and force it View suspicion by other Cocoa developers.
In general, follow the recommendations in the Coding Guide for a Cocoa document in Apple Developer Connection , and other developers will be able to pick up and understand your code, and your code will work well with all Cocoa functions that use runtime introspection.
A window controller class might look like this using my conventions:
// EmployeeWindowController.h #import <AppKit/NSWindowController.h> @interface EmployeeWindowController : NSWindowController { @private // model object this window is presenting Employee *_employee; // outlets connected to views in the window IBOutlet NSTextField *nameField; IBOutlet NSTextField *titleField; } - (id)initWithEmployee:(Employee *)employee; @property(readwrite, retain) Employee *employee; @end // EmployeeWindowController.m #import "EmployeeWindowController.h" @implementation EmployeeWindowController @synthesize employee = _employee; - (id)initWithEmployee:(Employee *)employee { if (self = [super initWithWindowNibName:@"Employee"]) { _employee = [employee retain]; } return self; } - (void)dealloc { [_employee release]; [super dealloc]; } - (void)windowDidLoad { // populates the window controls, not necessary if using bindings [nameField setStringValue:self.employee.name]; [titleField setStringValue:self.employee.title]; } @end
You will see that I use an instance variable that references Employee directly in my -init and -dealloc , while I use the property in other methods. This is usually a good template with properties: just ever touch the base instance variable for the property in initializers, in -dealloc , and in getter and setter for the property.