Saturday, June 22, 2013

Extra Interface in Implementation file

From Xcode 4.3 or so we started seeing implementation files with interfaces in them.  Kind of like:

@interface ViewController ()

@end


@implementation ViewController

end


This is a class extension.  It is intended to declare private instance variables.  It was inrtoduced to tackle the problem with categories as they make the methods public and data hiding capability of classes is compensated.

Source:
http://stackoverflow.com/questions/11594391/why-is-there-interface-above-implementation
http://stackoverflow.com/questions/10647913/declare-interface-inside-implementation-file-objective-c

No comments:

Post a Comment