V.V*_*V.V 8 objective-c iphone-sdk-3.0
如何在Objective-C中的单个函数中传递多个参数?我想传递2个整数值,返回值也是整数.我想使用新的Objective-C语法,而不是旧的C/C++语法.
Jay*_*Jay 36
在objective-c中它真的非常容易.这是你在C中的方式:
int functName(int arg1, int arg2)
{
// Do something crazy!
return someInt;
}
Run Code Online (Sandbox Code Playgroud)
这仍然适用于objective-c,因为它与C的兼容性,但目标-c方式是:
// Somewhere in your method declarations:
- (int)methodName:(int)arg1 withArg2:(int)arg2
{
// Do something crazy!
return someInt;
}
// To pass those arguments to the method in your program somewhere:
[objectWithOurMethod methodName:int1 withArg2:int2];
Run Code Online (Sandbox Code Playgroud)
祝你好运!
| 归档时间: |
|
| 查看次数: |
23233 次 |
| 最近记录: |