0

I would like to hide some methods that I made personally when using them in an other object.

How can hide those methods? If I don't define in '.h' (header file), is this possible?

[part of .h header file]

- (void) sequence1; //<= For example, I would like to hide it.
- (void) sequence2;
- (void) sequence3;
- (void) sequence4;
- (void) sequence5;
- (void) sequence6;
- (void) mcpSelect;
- (void) replay;
- (void) myTurn;

- (IBAction)kaPressed:(id)sender;
- (IBAction)baPressed:(id)sender;
- (IBAction)boPressed:(id)sender;
S.J. Lim
  • 3,095
  • 3
  • 37
  • 55

2 Answers2

0

If by "hide" you are just trying to make sure they don't end up in the public interface of your class, then you can leave them out of the .h file so no other classes will see the methods when they import your header file.

Then, in your .m file, you can declare the additional methods as a category against your class:

@interface uvSecondScreen (PrivateMethods)
-(void)privateMethod1;
-(void)privateMethod2;
@end

@implementation uvSecondScreen
// Implementation of all public methods declared in uvSecondScreen.h

-(void)privateMethod1 {
    NSLog(@"Entered privateMethod1");
}

-(void)privateMethod2 {
    NSLog(@"Entered privateMethod2");
}
@end
Tim Dean
  • 8,253
  • 2
  • 32
  • 59
  • 1
    If you leave out the name, i.e. `@interface uvSecondScreen ()`, you get an extension. The advantage is that te compiler complains if a declared method is not implemented in the `@implementation` section for that class in the .m file. – Rudy Velthuis Aug 12 '11 at 02:50
0

Declare them in the implementation file with @private followed by @end By definition objective c has no private methods

Best way to define private methods for a class in Objective-C

Community
  • 1
  • 1