I was surprised when the following method definition compiled (using Apple LLVM 4.1):
- (void) testMethod:someArgument {
}
Notice the type of someArgument is missing. What’s the rule in Objective-C about specifying the types of method arguments?
The default argument type is
id. Even this will compile:This is a method that takes an
idas its argument and should return anid.Actually, not even the method name is necessary:
This can be called as:
Of course all of this is very bad practice and you should always specify the types (and the names).