Accessor Overrides


If in your project you are using Objective-C 2.0 properties with synthesized ivars, you sometimes may need to generate explicit accessors to handle lazy initialization or other things.  Accessorizer can generate those accessor stubs for you via the Action Menu or Action Panel.

Action Menu

Action Panel

The accessor style will be based on your settings for explicit 1.0 style accessors on in the Accessor Style TAB.



There are numerous options for Getter and Setter styles, but the ones you see selected are the most common patterns.

If you need to wrap your ivars in will/did access/change notifications, you can choose the Action Menu/Panel menu “Accessors + will/did” or the “w” keyboard shortcut.

You also have actions for Core Data accessors and To-Many Relationships.  Those are covered in the Core Data page.

NOTE: When generating accessor overrides, pay attention to your ARC Aware setting as this will affect how the accessors are generated.

Example: let’s say you have these properties and you want overrides for them.  First, you select the property statements and invoke the Accessorizer Action Panel Service (see Setup) via the keyboard shortcut shift-opt-cmd-0 (shift option command zero)

Next, bring up the Action Menu (or Action Panel).

Action Menu global hotkey: shift-ctrl-cmd-0 (shift control command zero).

Toggle ARC Aware via the keyboard shortcut “z” as needed.

Select Setter, Getter or Accessors (for both Getter and Setter).

Depending on your settings for prefix/suffix, and on your Getter and Setter settings, you may see output like this:

- (NSString *)name {

    return [[_name retain] autorelease];


- (void)setName:(NSString *)newName {

    if (_name != newName) {

        [_name release];

        _name = [newName copy];



- (NSString *)title {

    return [[_title retain] autorelease];


- (void)setTitle:(NSString *)newTitle {

    if (_title != newTitle) {

        [_title release];

        _title = [newTitle copy];



- (float)a {

    return _a;


- (void)setA:(float)newA {

    _a = newA;


- (float)b {

    return _b;


- (void)setB:(float)newB {

    _b = newB;


- (NSInteger)count {

    return _count;


- (void)setCount:(NSInteger)newCount {

    _count = newCount;


- (NSArray *)songs {

    return [[_songs retain] autorelease];


- (void)setSongs:(NSArray *)newSongs {

    if (_songs != newSongs) {

        [_songs release];

        _songs = [newSongs copy];



- (NSArray *)albums {

    return [[_albums retain] autorelease];


- (void)setAlbums:(NSArray *)newAlbums {

    if (_albums != newAlbums) {

        [_albums release];

        _albums = [newAlbums copy];



- (void)dealloc {


    [_name release], _name = nil;

    [_title release], _title = nil;


    [super dealloc];