Class: NSInvocation
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)
-
+ invocationWithMethodSignature:
Returns an NSInvocation object able to construct messages using a given method signature.
Instance Method Summary (collapse)
-
- argumentsRetained
Returns YES if the receiver has retained its arguments, NO otherwise.
-
- getArgument:atIndex:
Returns by indirection the receiver's argument at a specified index.
-
- getReturnValue:
Gets the receiver's return value.
-
- invoke
Sends the receiver’s message (with arguments) to its target and sets the return value.
-
- invokeWithTarget:
Sets the receiver’s target, sends the receiver’s message (with arguments) to that target, and sets the return value.
-
- methodSignature
Returns the receiver’s method signature.
-
- 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.
-
- selector
Returns the receiver’s selector, or 0 if it hasn’t been set.
-
- setArgument:atIndex:
Sets an argument of the receiver.
-
- setReturnValue:
Sets the receiver’s return value.
-
- setSelector:
Sets the receiver’s selector.
-
- setTarget:
Sets the receiver’s target.
-
- target
Returns the receiver’s target, or nil if the receiver has no target.
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.
Instance Method Details
- (Boolean) argumentsRetained
Returns YES if the receiver has retained its arguments, NO otherwise.
- (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.
- (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.
- (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.
- (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.
- (NSMethodSignature) methodSignature
Returns the receiver’s method signature.
- (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.
- (Symbol) selector
Returns the receiver’s selector, or 0 if it hasn’t been set.
- (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.
- (Object) setReturnValue(buffer)
Sets the receiver’s return value. This value is normally set when you send an invoke or invokeWithTarget: message.
- (Object) setSelector(selector)
Sets the receiver’s selector.
- (Object) setTarget(anObject)
Sets the receiver’s target.
- (Object) target
Returns the receiver’s target, or nil if the receiver has no target.