Up
Authors
- Richard Frith-Macdonald (
richard@brainstorm.co.uk
)
-
- Andrew Kachites McCallum (
mccallum@gnu.ai.mit.edu
)
-
Date: Generated at 2023-12-20 19:35:39 -0500
Copyright: (C) 1998,2003 Free Software Foundation, Inc.
- Declared in:
- Foundation/NSInvocation.h
Availability: OpenStep
The NSInvocation
class implements a
mechanism of constructing messages (as
NSInvocation
instances), sending these
to other objects, and handling the returned values.
An NSInvocation
object may contain a target
object to which a message can be sent, or may send
the message to an arbitrary object.
Each message
consists of a selector for that method and an
argument list. Once the message has been sent, the
invocation will contain a return value whose
contents may be copied out of it.
The target, selector, and arguments of an instance be
constructed dynamically, providing a great deal
of power/flexibility.
The sending of the message to the target object (using
the -invoke
or
-invokeWithTarget:
method) can be done at any time, but a standard use
of this is by the
[NSObject -forwardInvocation:]
method which is called whenever a method is not implemented by the class of the object to which it was sent.
Related to the class are two convenience macros...
NS_MESSAGE()
and
NS_INVOCATION()
... to allow easy construction of invocations with all
the arguments set up.
Instance Variables
Method summary
+ (
NSInvocation*)
invocationWithMethodSignature: (
NSMethodSignature*)_signature;
Availability: OpenStep
Returns an invocation instance which can be used to
send messages to a target object using the described
signature.
You must set the target and
selector (using
-setTarget:
and -setSelector:) before you attempt to use the
invocation.
Raises an
NSInvalidArgumentException if
the signature is
nil
.
- (BOOL)
argumentsRetained;
Availability: OpenStep
Returns a flag to indicate whether object arguments
of the invocation (including its target) are retained by
the invocation.
- (void)
getArgument: (void*)buffer
atIndex: (
NSInteger)index;
Availability: OpenStep
Copies the argument identified by index
into the memory location specified by the
buffer argument.
An
index of zero is the target object, an
index of one is the selector, so the
actual method arguments start at index 2.
- (void)
getReturnValue: (void*)buffer;
Availability: OpenStep
Copies the invocations return value to the location
pointed to by
buffer if a return value
has been set (see the
-setReturnValue:
method).
If there isn't a return value then
this method raises an exception.
- (void)
invoke;
Availability: OpenStep
Sends the message encapsulated in the invocation to
its target.
- (void)
invokeWithTarget: (id)anObject;
Availability: OpenStep
Sends the message encapsulated in the invocation to
anObject.
- (
NSMethodSignature*)
methodSignature;
Availability: OpenStep
Returns the method signature of the invocation.
- (void)
retainArguments;
Availability: OpenStep
Instructs the invocation to retain its object
arguments (including the target). The default is
not to retain them.
- (void)
retainArgumentsIncludingTarget: (BOOL)retainTargetFlag;
Availability: Not in OpenStep/MacOS-X, Base 1.11.1
Similar to -[NSInvocation retainArguments], but
allows the sender to explicitly control whether the
target is retained as well. Retaining the target is
sometimes not desirable (such as in
NSUndoManager), as retain loops could
result.
- (SEL)
selector;
Availability: OpenStep
Returns the selector of the invocation (the
argument at index 1)
- (void)
setArgument: (void*)buffer
atIndex: (
NSInteger)index;
Availability: OpenStep
Sets the argument identified by
index from
the memory location specified by the
buffer
argument.
Using an
index of 0
is equivalent to calling
-setTarget:
and using an argument of 1 is equivalent to
-setSelector:
Proper arguments start at
index 2.
NB. Unlike
-setTarget:
and
-setSelector:
the value of
buffer must be
a pointer to the argument to be set in the
invocation.
If
-retainArguments
was called, then any object argument set in the
receiver is retained by it.
- (void)
setReturnValue: (void*)buffer;
Availability: OpenStep
Sets the return value of the invocation to the item
that buffer points to.
- (void)
setSelector: (SEL)aSelector;
Availability: OpenStep
Sets the selector for the invocation.
- (void)
setTarget: (id)anObject;
Availability: OpenStep
Sets the target object for the invocation.
If
-retainArguments
was called, then the target is retained.
- (id)
target;
Availability: OpenStep
Returns the target object of the invocation.
- (BOOL)
targetRetained;
Availability: Not in OpenStep/MacOS-X, Base 1.11.1
Returns YES
if target has been
retained yet, NO
otherwise.
Instance Variables for NSInvocation Class
@public BOOL _argsRetained;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public void* _cframe;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public void* _info;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public unsigned int _numArgs;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public void* _retptr;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public void* _retval;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public SEL _selector;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public BOOL _sendToSuper;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public NSMethodSignature* _sig;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public id _target;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public BOOL _targetRetained;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@public BOOL _validReturn;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
- Declared in:
- Foundation/NSInvocation.h
Availability: Base
Likely to be changed/moved/removed at 1.17.0
Provides some minor extensions and some utility
methods to aid integration of
NSInvocation
with the Objective-C
runtime.
Method summary
- (BOOL)
sendsToSuper;
Availability: Base
Likely to be changed/moved/removed at 1.17.0
- (void)
setSendsToSuper: (BOOL)flag;
Availability: Base
Likely to be changed/moved/removed at 1.17.0
Sets the flag to tell the invocation that
it should actually invoke a method in the superclass of
the target rather than the method of the target itself.
This extension permits an invocation to act
like a regular method call sent to super in
the method of a class.
- Declared in:
- Foundation/NSInvocation.h
Availability: OpenStep
For use by macros only.
These methods are for
internal use only... not public API
They are
used by the
NS_INVOCATION()
and
NS_MESSAGE()
macros to help create invocations.
Method summary
+ (id)
_newProxyForInvocation: (id)target;
Availability: OpenStep
Warning the underscore at the start of the
name of this method indicates that it is private, for
internal use only, and you should not use the
method in your code.
Internal use.
+ (id)
_newProxyForMessage: (id)target;
Availability: OpenStep
Warning the underscore at the start of the
name of this method indicates that it is private, for
internal use only, and you should not use the
method in your code.
+ (
NSInvocation*)
_returnInvocationAndDestroyProxy: (id)proxy;
Availability: OpenStep
Warning the underscore at the start of the
name of this method indicates that it is private, for
internal use only, and you should not use the
method in your code.
- (id)
initWithMethodSignature: (
NSMethodSignature*)aSignature;
Availability: OpenStep
This is a designated initialiser for the class.
Subclasses
must override this method.
Initialised an invocation instance which can be
used to send messages to a target object using
aSignature.
You must set the target
and selector (using
-setTarget:
and -setSelector:) before you attempt to use the
invocation.
Raises an
NSInvalidArgumentException if
aSignature is
nil
.
Up