Contents

setArgument:atIndex:

Sets an argument of the receiver.

Declaration

- (void) setArgument:(void *) argumentLocation atIndex:(NSInteger) idx;

Parameters

  • argumentLocation:

    An untyped buffer containing an argument to be assigned to the receiver. See the discussion below relating to argument values that are objects.

  • idx:

    An integer specifying the index of the argument.

    Indices 0 and 1 indicate the hidden arguments self and _cmd, respectively; you should set these values directly with the Target and Selector properties. Use indices 2 and greater for the arguments normally passed in a message.

Discussion

This method copies the contents of buffer as the argument at index. The number of bytes copied is determined by the argument size.

When the argument value is an object, pass a pointer to the variable (or memory) from which the object should be copied:

NSArray *anArray;
[invocation setArgument:&anArray atIndex:3];

This method raises NSInvalidArgumentException if the value of index is greater than the actual number of arguments for the selector.

See Also

Related Documentation

Configuring an Invocation Object