The protocol implemented by all advice objects. More...
#import <AOCAdvice.h>
Public Member Functions | |
(void) | - adviceBefore: |
Where "before" advice is executed. | |
(BOOL) | - adviceInsteadOf: |
Where the "instead of" advice is executed. | |
(void) | - adviceAfter: |
Where "after" advice is executed. |
The protocol implemented by all advice objects.
In all of the methods, [inv imp]
is the actual IMP that the advice is running for. This will be different from [[inv target] methodForSelector:[inv selector]]
because the method has been swizzled.
The following code will crash because of infinite recursion:
[[inv target] performSelector:[inv selector]]
You can't call the selector that advice is running for without causing infinite recursion. If you want to call actual method the advice is running for, use [inv invoke]
without modifying the target, selector or IMP.
- (void) adviceAfter: | (id< AOCInvocationProtocol >) | inv | [optional] |
Where "after" advice is executed.
The invocation argument should have already been invoked by the time this method is called. The return value of the invocation argument may be modified here.
inv | The invocation after which this method is executing |
- (void) adviceBefore: | (id< AOCInvocationProtocol >) | inv | [optional] |
Where "before" advice is executed.
The invocation argument will be invoked after this method is called, with any modification made to it. This means that the arguments may be modified here before the actual method is invoked.
inv | The invocation before which this method is executing. |
- (BOOL) adviceInsteadOf: | (id< AOCInvocationProtocol >) | inv | [optional] |
Where the "instead of" advice is executed.
The invocation argument is only invoked if this method returns YES. Otherwise, the return value of the invocation should be set manually by calling either AOCInvocationProtocol::invoke or AOCInvocationProtocol::setReturnValue:
inv | The invocation instead of which this method is executing |