take example:
-(void)setName:(NSString *)name age:(int)age;
How would you call this method (in other words, the method’s name is setName but what is the “age” parameter doing in there) and what do the types in parentheses mean? Is it just a way to tell the compiler what types are being returned?
[ myObject setName: @"Adam" age:18 ];The
ageparameter is the second parameter in the method signature.The types in parentheses are the expected types for the argument. e.g.
nameis expecting only anNSStringandageis expecting only anint.The
-means that the method is an instance method, not a class method, which is denoted using a+instead.The type in parentheses right after the
-is the return type.This is a great site for learning the basics of Objective-C: CocoaDevCentral