0 votes
in Technology by (438k points)

What is the use of category in Objective-C?

1 Answer

0 votes
by (438k points)

You typically use a category to add methods to an existing class, such as one defined in the Cocoa frameworks. The added methods are inherited by subclasses and are indistinguishable at runtime from the original methods of the class. You can also use categories of your own classes to: Distribute the implementation of your own classes into separate source files — for example, you could group the methods of a large class into several categories and put each category in a different file. Declare private methods.

#import “SystemClass.h”

@interface SystemClass (CategoryName)

// method declarations

@end

...