What is the difference between category and extension in objective c?
Answer / Sumit Sharma
Both categories and extensions allow developers to add new methods to existing classes without modifying their original source code. However, there are some differences:n1. Category: It can be applied to any class at runtime, even if the class was not originally designed for the category. Categories have a separate header file (extension) that defines the interface and implementation of the new methods. They can also share the same name with other categories or extensions.n2. Extension: It is only available in Objective-C 2.0 or later versions, and it can be applied to any class, protocol, or namespace during development. Extensions should be used for adding properties and methods to a class that was designed for them. They must have the same name as the original source file.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the difference between a script and function?
How to sort array of dictionary in objective c?
Can we create dynamic classes in objective c? If yes, explain how to create with a valid use case?
What is .m file in xcode?
What is instance variable objective c?
What are objective c properties?
What is an instancetype?
Is there function overloading in objective-c?
Who invented objective c?
Is objective c difficult?
What is dictionary objective c?
How do you get closure?