Class similar to NSInvocation. More...
#import <AOCInvocationProtocol.h>
Inherited by AOCFFIInvocation.
Public Member Functions | |
(void) | - setSelector: |
Sets the selector of the invocation (_cmd variable). | |
(SEL) | - selector |
The selector to invoke. | |
(void) | - setTarget: |
Sets the object of the invocation (self variable). | |
(id) | - target |
The target to invoke with. | |
(void) | - setImp: |
Sets the IMP to invoke. | |
(IMP) | - imp |
The IMP to invoke (can be NULL). | |
(void) | - setArgument:atIndex: |
Works exactly like -[NSInvocation setArgument:atIndex:] . | |
(void) | - getArgument:atIndex: |
Works exactly like -[NSInvocation getArgument:atIndex:] . | |
(void) | - setReturnValue: |
Works exactly like -[NSInvocation setReturnValue:] . | |
(void) | - getReturnValue: |
Works exactly like -[NSInvocation getReturnValue:] . | |
(size_t) | - returnValueSize |
The number of bytes required to hold the return value. | |
(void) | - invoke |
Works (almost) like -[NSInvocation invoke] . |
Class similar to NSInvocation.
Classes conforming to AOCInvocationProtocol work almost exactly like NSInvocation objects.
The main difference between NSInvocation and AOCInvocationProtocol objects is that AOCInvocationProtocol objects can take a specific IMP to execute. This is useful when you want to run a specific method regardless of whether it is attached to a selector or not. This is important in AspectObjectiveC because methods are swizzled, and the correct IMP may not be the one attached to the selector.
AOCInvocationProtocol implement NSCopying. NSInvocation also implements NSCopying, but it doesn't copy the arguments. AOCInvocationProtocol copies everything properly.
- (void) getArgument: | (void *) | argPtr | ||
atIndex: | (NSUInteger) | idx | ||
Works exactly like -[NSInvocation getArgument:atIndex:]
.
- (void) getReturnValue: | (void *) | returnValPtr |
Works exactly like -[NSInvocation getReturnValue:]
.
- (IMP) imp |
The IMP to invoke (can be NULL).
- (void) invoke |
Works (almost) like -[NSInvocation invoke]
.
If [self imp]
is NULL, then this method works exactly like NSInvocation. Otherwise, [self imp]
is invoked instead of the actual IMP attached to the selector of the target.
- (size_t) returnValueSize |
The number of bytes required to hold the return value.
- (SEL) selector |
The selector to invoke.
- (void) setArgument: | (void *) | argPtr | ||
atIndex: | (NSUInteger) | idx | ||
Works exactly like -[NSInvocation setArgument:atIndex:]
.
- (void) setImp: | (IMP) | imp |
Sets the IMP to invoke.
When [self imp]
is set to NULL, the [self invoke]
will behave like NSInvocation and invoke the IMP returned from:
[[self target] methodForSelector:[self selector]]
However, [self invoke]
will execute [self imp]
if it is not NULL. The IMP will be passed [self target]
and [self selector]
as self
and _cmd
respectively.
imp | The IMP to invoke, or NULL if the IMP should be looked up with the target and selector like NSInvocation does |
- (void) setReturnValue: | (void *) | returnValPtr |
Works exactly like -[NSInvocation setReturnValue:]
.
- (void) setSelector: | (SEL) | selector |
Sets the selector of the invocation (_cmd variable).
Unlike NSInvocation, this may not change the method that is invoked. If [self imp] == nil
, then [self invoke]
will work exactly the same as NSInvocation. If [self imp]
is not nil, then [self imp]
will be invoked regardless of what [self selector] is.
selector | The selector to invoke |
- (void) setTarget: | (id) | target |
Sets the object of the invocation (self variable).
target | The target to invoke with |
- (id) target |
The target to invoke with.