Possible Duplicate:
Best way to define private methods for a class in Objective-C
Hi, Can i have private methods for any class in a cocoa application? if yse, how?
Possible Duplicate:
Best way to define private methods for a class in Objective-C
Hi, Can i have private methods for any class in a cocoa application? if yse, how?
Yes you can!
in your *.m file (Implementation)
#import "MyClass.h"
@interface MyClass()
- (void)privateMethod();
@end
@implementation MyClass
- (void)dealloc {
[super dealloc];
}
- (void)privateMethod
{
NSlog(@"myPrivateMethod");
}
@end
If program Java, for example, I'd say to you that private methods are not simple to implement.
To implement them, you should implement, in the .m file, interfaces containing the signature of those methods you want to be private. Since imports "always" regards to .h files, this solution serves as private method implementation solution.
Resuming: use .h to expose your public methods. Use interfaces inside the .m to enable methods to be used as private.