Is the interface declared twice? - Objective-C

I am new to Objective-C and I am looking through many examples to wrap my head around myself. I came across this code:

@interface ImagePickerHelper : NSObject <UIImagePickerControllerDelegate, UIPopoverControllerDelegate, UINavigationControllerDelegate> //Blah Blah @end @interface ImagePickerHelper () //Blah Blah @end 

In googling, I found out that they define the superclass and delegates (which, by the way, I know of zilch about) after the interface name.

But why is the interface here declared twice?

+4
source share
2 answers

No, it is not declared twice, it is a class interface (anonymous category) that is created to store methods that you want to keep in your class, for methods that you do not want another class to see or interact with ..

People often declare a standard category with a name (usually "private") for storing private methods, but the main advantage of using an anonymous category for a named category is that the compiler will complain if you do not implement a method declared in an anonymous category.

I noticed that it is created by default with Xcode 4.3 onwards.

Putting methods into this extension A class is like declaring private methods in Java or C ++ ...

+3
source

The second "@interface" that you see (possibly in the .m file) is an extension of the class and is probably intended for private methods (well, private, in the sense that the compiler will generate warnings "do not respond to"),

+2
source

Source: https://habr.com/ru/post/1415864/


All Articles