Copyright ©1995 by NeXT Computer, Inc. All Rights Reserved.
NXReference |
Adopted By: | IXFileFinder IXStoreBlock NXConnection NXInvalidationNotifier NXProxy | |
Declared In: | machkit/reference.h |
Protocol Description |
The NXReference protocol defines a set of methods for implementing simple reference counting of objects. This allows an object to be referenced multiple times without each client needing to assume that the referenced object may be in use by others. A client of the referenced object can simply send it a free message when finished; if the object still has outstanding references, it doesn't free itself. |
Method Types |
Adding or deleting a reference | addReference |
free |
Getting the number of references |
references |
Instance Methods |
addReference |
addReference |
Increments the number of references to the receiver and returns self. |
free |
free |
Decrements the receiver's reference count, returning self if the reference count remains greater than 0. If the reference count becomes 0, this method deallocates the receiver's storage and returns nil.
A typical implementation for a reference counted object that is vended over a Distributed Objects connection might look like this: |
- free
{
refs--;
if (refs > 0) return self;
[NXConnection removeObject:self];
return [super free];
}
references |
(unsigned int)references |
Returns the number of references to the receiver. |