- (return_type)instanceMethod1:(param1_type)param1_varName :(param2_type)param2_varName;
- (return_type)instanceMethod2WithParameter :(param1_type)param1_varName andOtherParameter:(param2_type)param2_varName;
The code above is roughly equivalent to the following C++
return_type instanceMethod1(param1_type param1_varName, param2_type param2_varName); return_type instanceMethod2WithParameter(param1_type param1_varName, param2_type param2_varName=default);
Note that instanceMethod2WithParameter:andOtherParameter: demonstrates the interleaving of selector segments with argument expressions, for which there is no direct equivalent in C/C++. ----?
函数参数语法
:(参数类型) 参数名称
In some cases (e.g. when writing system APIs) it is useful to add descriptive text before each parameter.
描述文字:(参数类型) 参数名称
函数调用:
- (int)changeColorToRed:(float)red green:(float)green blue:(float)blue; [myColor changeColorToRed:5.0 green:2.0 blue:6.0];
The syntax allows pseudo-naming of arguments.