How to define a method that takes multiple parameters

- by

I keep forgetting how to do this… don’t ask me why, it’s not that difficult! So here’s how we define one:

- (void)methodName:(NSString *)parameterOne methodNameContinues:(NSString *)parameterTwo;

Add more parameters as you please. In theory, the method name is split across these multiple descriptive parts before each parameter is defined. However in reality I find it easier to just repeat the parameter names in each section, like this:

- (void)methodName:(NSString *)theString nextString:(NSString *)theNextString;

or

- (void)callingNames:(NSString *)firstName lastName:(NSString *)lastName;


If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site witout any pesky ads! More details here.

Add your voice!

This site uses Akismet to reduce spam. Learn how your comment data is processed.