AOCAdvice Class Reference

A convenient base class for advice objects. More...

#import <AOCAdvice.h>

Inheritance diagram for AOCAdvice:
<AOCAdviceProtocol>

List of all members.

Public Member Functions

(id< AOCInvocationProtocol >) - invocation

Detailed Description

A convenient base class for advice objects.

Advice objects needn't be a subclass of AOCAdvice, they must simply implement AOCAdviceProtocol. AOCAdvice is only provided for convenience.

The AOCAdvice class invokes "before", "instead of", and "after" methods with the same arguments as the actual method that the advice is running for. For example, if the advice is installed for the selector:

    -(double)divide:(double)numerator by:(double)denominator;

AOCAdvice will run these methods on itself if they exist:

    -(double)adviceBeforeDivide:(double)numerator by:(double)denominator;
    -(double)adviceInsteadOfDivide:(double)numerator by:(double)denominator;
    -(double)adviceAfterDivide:(double)numerator by:(double)denominator;

The return values of -adviceBefore[sel] and -adviceAfter[sel] are ignored.

In -adviceBefore[sel], the arguments may be modified via [[self invocation] setArgument:... atIndex:...] before the actual method is called. Be aware that the first argument is at index 2.

If -adviceInsteadOf[sel] is implemented, then the advice will replace the actual method. The actual method will not be called, and the return value from -adviceInsteadOf[sel] is treated as the actual return value.

In -adviceAfter[sel], the return value may be modified via [[self invocation] setReturnValue:...] after the actual method has been called. You can also retreive the return value of the actual method via [[self invocation] getReturnValue:...].


Member Function Documentation

- (id< AOCInvocationProtocol >) invocation  
Returns:
The invocation representing the actual method that the advice is running for, or nil if not called from within an advice method. The object returned should not be retained for later use, because it will be invalid after the advice method has returned.
See also:
AOCInvocationProtocol

The documentation for this class was generated from the following files:
 All Classes Functions
Generated by  doxygen 1.6.3