Search code examples
objective-cioscocoa-touchclass-extensions

Two interfaces in *.h and *.m files


Sorry for my English, let speak from my heart :) In one project which I work, I noticed an interesting moment.

In *.h file declared interface:

@interface FrontViewController : UIViewController
...
@end

And in *.m file I found another interface.

@interface FrontViewController()

// Private Properties:
@property (retain, nonatomic) UIPanGestureRecognizer *navigationBarPanGestureRecognizer;

// Private Methods:
- (IBAction)pushExample:(id)sender;

@end

@implementation FrontViewController
...
@end

Why is it needed? And what's the point? -I think that this is for convenience. Yes?


Solution

  • That's a class extension. It's usually used to declare private methods and properties for a class.

    Read about it here.