Why Xcode 4.3 Put @interface ClassName () in the implementation file?

I created the class in Xcode 4.3 and it created the header and implementation files with @interface and @implementation in the right places, but the implementation file also has @interface, like this:

@interface MyClassName () @end 

Why does Xcode put this in the implementation file and what is it for?

Thanks Kurz

+8
xcode xcode4 cocoa
source share
1 answer

Xcode automatically creates a class extension that allows the implementation of "private" methods.
Class extensions are unnamed categories and introduced with Objective-C 2.0.

One of the advantages of class extensions is that the compiler will warn you if you forget to implement one of the methods declared in the anonymous interface.

+13
source share

All Articles