Method Signatures
You've often seen them in use - those mysterious values used in method attributes to tell the Objective-C runtime what data types to pass to and expect back from your methods. The codes are based on Objective-C's type encoding scheme. Unless otherwise noted, all variables are scalars when used in Perl.
Many types are fully supported, and can be declared as parameter and/or return types for Perl methods, as well as being passed to and returned from Objective-C methods.
Supported Type Encodings
- c/C
- Signed/unsigned char. Contrary to what you might think, these are not characters; they're integer values that can range from -127 to 127 (signed) or 0 to 255 (unsigned).
- i/I
- Signed/unsigned int. These are 32-bit integer values that can range from -2,147,483,647 to 2,147,483,647 (signed) or 0 to 4,294,967,295 (unsigned).
- s/S
- Signed/unsigned short. 16-bit integer values that can range from -32,767 to 32,767 (signed) or 0 to 65,535 (unsigned).
- l/L
- Signed/unsigned long. Integer values with the same range as signed/unsigned int above.
- f/d
- Float/double. Single and double-precision floating point numbers.
- v
- Void. Used only as a return type, to indicate that nothing is returned.
- *
- C strings, declared in C/Objective-C/C++ as "char*".
- @
- Objects. Technically speaking, an object of any class. In practice, the Cocoa documentation will specify the class (or parent class) of the objects your methods will be called with, and what object classes are expected to be passed to Cocoa methods.
- ^
- An untyped pointer, declared in C/Objective-C/C++ as "void*". Returned to Perl as an integer value - it may be dereferenced by using pack()/unpack().
- :
- An Objective-C selector, which is the name of a message.
- {
- Structures. NSPoint, NSRange, NSRect, NSSize, and OSType structs are supported.
Unsupported Type Encodings
- q/Q
- Long long/unsigned long long. 64-bit integer values.
- #
- An Objective-C class struct.
- [
- A C array.
- (
- A C union.
- b
- A C bit field