It is OK to not declare methods in the header yes, under certain circumstances. For example, when using ARC, the compiler usually needs to know the signature of the method so that it can do the right thing. But basically all of this means that wherever you use a method, it should know about the method that you are calling.
Since you are talking about the Builder interface, this is slightly different in that it will know about all the methods, because it can “see” the whole context of your header and implementation files and know that the method exists. that is, in my terminology above, the method was defined before its use.
Regarding the definition before use, the generally accepted approach is as follows:
Define the method in the interface file (.h). eg:.
Myclass.h
@interface MyClass : NSObject - (void)someMethod; @end
Myclass.m
@implementation MyClass - (void)someMethod { // do something } @end
Define a method in the class continuation category. eg:.
Myclass.h
@interface MyClass : NSObject @end
Myclass.m
@interface MyClass () - (void)someMethod; @end @implementation MyClass - (void)someMethod {
source share