I’m familiar with Objective-C class extensions in class main implementation file, but curious for what the new Xcode 4.4 “An Objective-C class extension header” file template is intended for?
I’m familiar with Objective-C class extensions in class main implementation file, but curious for
Share
Class extensions must be implemented in the main
@implementationblock, but the declaration can be anywhere.Extensions are used to add something to the class interface that you do not want to be public, and therefore cannot put in the public class declaration header.
Declaring the extension in the same file of the implementation, which you are familiar with, is used when the extension is only used by the class implementation itself.
Declaring the extension in a separate header, which is what the template is for, is useful when you develop a framework. The extension header will not be part of the set of public headers, but will be used internally by more than one implementation file of the framework.
You can think of it as private to framework instead of private to class.