objective-c function

1815 단어 Objective-C
- (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 .
 
http://en.wikipedia.org/wiki/Objective-C

좋은 웹페이지 즐겨찾기