Locking

 

For Objective-C 1.0 explicit accessors, Accessorizer offers a few locking options via Accessorizer’s main interface panel.  There is no LOCK action in the Action Menu or Action Panel.

Lock accessors switch must be turned on to enable this panel

With these settings and the following ivars, you would get the following results.

QVNote *note;

float freq;

NSMutableArray *artists;

BOOL fast;

NSLock *_noteLock;

NSLock *_freqLock;

NSLock *_artistsLock;

NSLock *_fastLock;



- (QVNote *)note;

- (void)setNote:(QVNote *)newNote;

- (float)freq;

- (void)setFreq:(float)newFreq;

- (NSMutableArray *)artists;

- (void)setArtists:(NSMutableArray *)newArtists;

- (BOOL)fast;

- (void)setFast:(BOOL)flag;


- (QVNote *)note {

    [_noteLock lock];

    QVNote *result = [_note retain];

    [_noteLock unlock];

    return [result autorelease];

}

- (void)setNote:(QVNote *)newNote {

    [_noteLock lock];

    if (_note != newNote) {

        [_note release];

        _note = [newNote retain];

    }

    [_noteLock unlock];

}


- (float)freq {

    return _freq;

}

- (void)setFreq:(float)newFreq {

    [_freqLock lock];

    _freq = newFreq;

    [_freqLock unlock];

}

- (NSMutableArray *)artists {

    [_artistsLock lock];

    NSMutableArray *result = [_artists retain];

    [_artistsLock unlock];

    return [result autorelease];

}

- (void)setArtists:(NSMutableArray *)newArtists {

    [_artistsLock lock];

    if (_artists != newArtists) {

        [_artists release];

        _artists = [newArtists retain];

    }

    [_artistsLock unlock];

}


- (BOOL)fast {

    return _fast;

}

- (void)setFast:(BOOL)flag {

    [_fastLock lock];

    _fast = flag;

    [_fastLock unlock];

}


- (void)dealloc {

   

    [_note release], _note = nil;

    [_artists release], _artists = nil;

   

    [super dealloc];

}