7

why do I see @interface twice( inside .h and .m files in this UIViewController files I've created. the one in the .m seems to be like a constructor. is it?

.h file

@interface BlackTimer : UIViewController 


@end

.m file

@interface ViewController ()

@end
  • possible duplicate of [Difference between @interface definition in .h and .m file](http://stackoverflow.com/questions/3967187/difference-between-interface-definition-in-h-and-m-file) – jscs Jun 07 '12 at 19:36

3 Answers3

7

usually in the .m file you put all the declarations for private methods

it's a good use to write the word "private" (or something similar) like this:

@interface ViewController (private)

-(void)myPrivateMethod;

@end
meronix
  • 6,175
  • 1
  • 23
  • 36
7

The @interface in the .m file is called a class extension. Here is a good link explaining it. Hope this helps. And here is the Apple documentation on class extensions.

pasawaya
  • 11,515
  • 7
  • 53
  • 92
-1

The @interface ViewController () definition in the implementation file (.m) is an anonymous Category. It allows to define ivars, properties and messages your class implements without exposing them to other objects importing your public interface (.h).

Luca Corti
  • 535
  • 5
  • 14