Class: NSInvocation

Inherits:
NSObject show all

Overview

An NSInvocation is an Objective-C message rendered static, that is, it is an action turned into an object. NSInvocation objects are used to store and forward messages between objects and between applications, primarily by NSTimer objects and the distributed objects system.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Class Method Details

+ (NSInvocation) invocationWithMethodSignature(signature)

Returns an NSInvocation object able to construct messages using a given method signature. The new object must have its selector set with setSelector: and its arguments set with setArgument:atIndex: before it can be invoked. Do not use the alloc/init approach to create NSInvocation objects.

Parameters:

Returns:

Instance Method Details

- (Boolean) argumentsRetained

Returns YES if the receiver has retained its arguments, NO otherwise.

Returns:

  • (Boolean)

- (Object) getArgument(buffer, atIndex:index)

Returns by indirection the receiver's argument at a specified index. This method copies the argument stored at index into the storage pointed to by buffer. The size of buffer must be large enough to accommodate the argument value. When the argument value is an object, pass a pointer to the variable (or memory) into which the object should be placed:This method raises NSInvalidArgumentException if index is greater than the actual number of arguments for the selector.

Parameters:

  • buffer (Object)

    An untyped buffer to hold the returned argument. See the discussion below relating to argument values that are objects.

  • index (Integer)

    An integer specifying the index of the argument to get.Indices 0 and 1 indicate the hidden arguments self and _cmd, respectively; these values can be retrieved directly with the target and selector methods. Use indices 2 and greater for the arguments normally passed in a message.

Returns:

- (Object) getReturnValue(buffer)

Gets the receiver's return value. Use the NSMethodSignature method methodReturnLength to determine the size needed for buffer:When the return value is an object, pass a pointer to the variable (or memory) into which the object should be placed:If the NSInvocation object has never been invoked, the result of this method is undefined.

Parameters:

  • buffer (Object)

    An untyped buffer into which the receiver copies its return value. It should be large enough to accommodate the value. See the discussion below for more information about buffer.

Returns:

- (Object) invoke

Sends the receiver’s message (with arguments) to its target and sets the return value. You must set the receiver’s target, selector, and argument values before calling this method.

Returns:

- (Object) invokeWithTarget(anObject)

Sets the receiver’s target, sends the receiver’s message (with arguments) to that target, and sets the return value. You must set the receiver’s selector and argument values before calling this method.

Parameters:

  • anObject (Object)

    The object to set as the receiver’s target.

Returns:

- (NSMethodSignature) methodSignature

Returns the receiver’s method signature.

Returns:

- (Object) retainArguments

If the receiver hasn’t already done so, retains the target and all object arguments of the receiver and copies all of its C-string arguments. Before this method is invoked, argumentsRetained returns NO; after, it returns YES.For efficiency, newly created NSInvocations don’t retain or copy their arguments, nor do they retain their targets or copy C strings. You should instruct an NSInvocation to retain its arguments if you intend to cache it, since the arguments may otherwise be released before the NSInvocation is invoked. NSTimers always instruct their NSInvocations to retain their arguments, for example, because there’s usually a delay before an NSTimer fires.

Returns:

- (Symbol) selector

Returns the receiver’s selector, or 0 if it hasn’t been set.

Returns:

- (Object) setArgument(buffer, atIndex:index)

Sets an argument of the receiver. 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:This method raises NSInvalidArgumentException if the value of index is greater than the actual number of arguments for the selector.

Parameters:

  • buffer (Object)

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

  • index (Integer)

    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 setTarget: and setSelector: methods. Use indices 2 and greater for the arguments normally passed in a message.

Returns:

- (Object) setReturnValue(buffer)

Sets the receiver’s return value. This value is normally set when you send an invoke or invokeWithTarget: message.

Parameters:

  • buffer (Object)

    An untyped buffer whose contents are copied as the receiver’s return value.

Returns:

- (Object) setSelector(selector)

Sets the receiver’s selector.

Parameters:

  • selector (Symbol)

    The selector to assign to the receiver.

Returns:

- (Object) setTarget(anObject)

Sets the receiver’s target.

Parameters:

  • anObject (Object)

    The object to assign to the receiver as target. The target is the receiver of the message sent by invoke.

Returns:

- (Object) target

Returns the receiver’s target, or nil if the receiver has no target.

Returns: