- Inherits from:
- NSObject
- Conforms to:
- NSObject
- (NSObject)
Declared in:
- Foundation/NSMethodSignature.h
An NSMethodSignature records type information for the arguments and return value of a method. It's used to forward messages that the receiving object doesn't respond to-most notably in the case of distributed objects. An NSMethodSignature is typically created using NSObject's methodSignatureForSelector: instance method. It's then used to create an NSInvocation, 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 is encoded using the information in the NSMethodSignature and sent to the real object represented by the receiver of the message.
An NSMethodSignature presents its argument types by index with the getArgumentTypeAtIndex: method. The hidden arguments for every method, self and _cmd, are at indices 0 and 1 respectively. The arguments normally specified in a message invocation follow these. In addition to the argument types, an NSMethodSignature offers the total number of arguments with numberOfArguments, the total stack frame length occupied by all arguments with frameLength (this varies with hardware architecture), and the length and type of the return value with methodReturnLength and methodReturnType. Finally, applications using distributed objects can determine if the method is asynchronous with the isOneway method.
For more information about the nature of a method, including the hidden arguments, see Object-Oriented Programming and the Objective-C Language.
- Querying attributes
- - frameLength
- - getArgumentTypeAtIndex:
- - isOneway
- - numberOfArguments
- - methodReturnLength
- - methodReturnType
- (unsigned)frameLength
- (const char *)getArgumentTypeAtIndex:(unsigned)index
Argument types are given as C strings with Objective-C type encoding. This encoding is implementation-specific, so applications should use it with caution.
- (BOOL)isOneway
- (unsigned)methodReturnLength
See Also: - methodReturnType
- (const char *)methodReturnType
See Also: - methodReturnLength
- (unsigned)numberOfArguments