Home > DeveloperSection > Interviews > What is the use of categories in iOS?

Posted on    August-03-2015 11:47 PM

 iPhone iPhone  Ios  Objective C 
 1 Answer(s)
  324  View(s)
Rate this:

Felix Pickles
Felix Pickles

Total Post:3

Posted on    August-03-2015 11:47 PM

A Category is a feature of the Objective-C language that enables you to add methods (interface and implementation) to a class without having to make a subclass. There is no runtime difference—within the scope of your program—between the original methods of the class and the methods added by the category. The methods in the category become part of the class type and are inherited by all the class’s subclasses.

As with delegation, categories are not a strict adaptation of the Decorator pattern, fulfilling the intent but taking a different path to implementing that intent. The behavior added by categories is a compile-time artifact, and is not something dynamically acquired. Moreover, categories do not encapsulate an instance of the class being extended.

Modified On Aug-03-2015 11:48:11 PM

Don't want to miss updates? Please click the below button!

Follow MindStick