Class: NSMethodSignature
Overview
An NSMethodSignature object records type information for the arguments and return value of a method. It is used to forward messages that the receiving object does not respond to—most notably in the case of distributed objects. You typically create an NSMethodSignature object using NSObject’s methodSignatureForSelector: instance method (on OS X v10.5 and later you can also use signatureWithObjCTypes:). It is then used to create an NSInvocation object, which is passed as the argument to a forwardInvocation: message to send the invocation on to whatever other object can handle the message. In the default case, NSObject invokes doesNotRecognizeSelector:, which raises an exception. For distributed objects, the NSInvocation object is encoded using the information in the NSMethodSignature object and sent to the real object represented by the receiver of the message.
Class Method Summary (collapse)
-
+ signatureWithObjCTypes:
Returns an NSMethodSignature object for the given Objective C method type string.
Instance Method Summary (collapse)
-
- frameLength
Returns the number of bytes that the arguments, taken together, occupy on the stack.
-
- getArgumentTypeAtIndex:
Returns the type encoding for the argument at a given index.
-
- isOneway
Returns a Boolean value that indicates whether the receiver is asynchronous when invoked through distributed objects.
-
- methodReturnLength
Returns the number of bytes required for the return value.
-
- methodReturnType
Returns a C string encoding the return type of the method in Objective-C type encoding.
-
- numberOfArguments
Returns the number of arguments recorded in the receiver.
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
+ (NSMethodSignature) signatureWithObjCTypes(types)
Returns an NSMethodSignature object for the given Objective C method type string.
Instance Method Details
- (Integer) frameLength
Returns the number of bytes that the arguments, taken together, occupy on the stack. This number varies with the hardware architecture the application runs on.
- (const char) getArgumentTypeAtIndex(index)
Returns the type encoding for the argument at a given index. Indices begin with 0. The hidden arguments self (of type id) and _cmd (of type SEL) are at indices 0 and 1; method-specific arguments begin at index 2. Raises NSInvalidArgumentException if index is too large for the actual number of arguments.Argument types are given as C strings with Objective-C type encoding. This encoding is implementation-specific, so applications should use it with caution.
- (Boolean) isOneway
Returns a Boolean value that indicates whether the receiver is asynchronous when invoked through distributed objects. If the method is oneway, the sender of the remote message doesn’t block awaiting a reply.
- (Integer) methodReturnLength
Returns the number of bytes required for the return value.
- (const char) methodReturnType
Returns a C string encoding the return type of the method in Objective-C type encoding. This encoding is implementation-specific, so applications should use it with caution.
- (Integer) numberOfArguments
Returns the number of arguments recorded in the receiver. There are always at least 2 arguments, because an NSMethodSignature object includes the hidden arguments self and _cmd, which are the first two arguments passed to every method implementation.