Aar*_*onG 2 iphone xcode static boolean objective-c
这是用于iPhone的Xcode中的Objective-C.
我在main.m中有一个方法:
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
//I want to call the method here//
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
static BOOL do_it_all () {
//code here//
}
Run Code Online (Sandbox Code Playgroud)
如何从main.m调用do_it_all方法?
您可以正常调用它,只要您在调用之前已经声明了该函数.移动上面的函数定义main()或添加上面的以下行:
static BOOL do_it_all ();
Run Code Online (Sandbox Code Playgroud)
就个人而言,我认为前者更容易,但如果你在函数之间存在循环依赖关系,那么没有函数原型就无法解决.
当您在C/Objective-C/etc中添加函数原型时.它们经常出现在header(.h)文件中,但如果所有内容都在main.m中,那么这可能是一种过度杀伤力.
| 归档时间: |
|
| 查看次数: |
1940 次 |
| 最近记录: |