This is Objective-C, in Xcode for the iPhone.
I have a method in 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//
}
How do I call the do_it_all method from main.m?
You can call it normally, so long as you’ve already declared the function before you call it. Either move the function definition above
main()or add the following line above:Personally, I think the former is easier, but if you have circular dependencies between functions, it can be impossible to resolve without function prototypes.
When you do add function prototypes in C/Objective-C/etc. they are frequently in a header (
.h) file, but if everything is in main.m this is probably overkill.