Asked by: Soralla Assoreia
asked in category: General Last Updated: 20th January, 2020

What is a category in Objective C and when is it used?

Categories provide the ability to add functionality to an object without subclassing or changing the actual object. A handy tool, they are often used to add methods to existing classes, such as NSString or your own custom objects.

Click to see full answer.

Likewise, people ask, how do you add a category in Objective C?

To add a category, go to File -> New File…, and select “Objective-C category” from the “Cocoa Touch” tab under iOS. This will bring up an additional window, where you can name the Category in the “Category” textfield. You then type or select the class you want to add it to, and it will output 2 very simple files.

Also Know, what is posing in Objective C? Objective-C Posing. Objective-C permits a class to wholly replace another class within a program. The replacing class is said to "pose as" the target class. For the versions that supported posing, all messages sent to the target class are instead received by the posing class.

Hereof, what is the difference between category and extension in Objective C?

Categories are an Objective-C language feature that let you add new methods to an existing class. Extensions are a special case of categories that let you define methods that must be implemented in the main implementation block.

What is category in iOS?

A category allows you to add methods to an existing class—even to one for which you do not have the source. Categories are a powerful feature that allows you to extend the functionality of existing classes without subclassing.

20 Related Question Answers Found

What is a category in Objective C?

What is difference between category and extension in iOS?

What is a protocol in Objective C?

What is category in iOS Swift?

How do I create a class in Xcode?

What is Objective C used for?

What is a category extension?

What is the difference between class and category?

What is unnamed category in IOS?

What is extension in Swift?

What are the differences between copy and retain?

What are iOS protocols?

What is protocol in iOS Swift?