Reputation: 881
if i want to create a helper method in my .m file. its call it -(void) helpMeDoSomething... etc. do i need to declare the function prototype in the .h file like in c/c++ or just declaring it in the .m file is enough
Upvotes: 0
Views: 216
Reputation: 185852
Neither C, C++, nor Objective-C require function declarations to be in the header file. They simply have to be declared before they are used, and the definition in the .m file can serve as the declaration.
Upvotes: 2
Reputation: 55334
In order for other classes to see the method, its signature must be in the header file. If you are using the method in the same class that it is defined in, it does not need to be in the header file.
Upvotes: 1
Reputation: 32883
As in C/C++, you can declare it in your .m
file as long as you declare it before you use it, and as long as you don't need it somewhere else.
Upvotes: 0
Reputation: 124997
Put the prototype in the .h file if you want to make it available to be called from code in other files. You can put it in the .m file if it will only be called from inside that one file.
Upvotes: 0