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 |
Who calls dealloc method? Can we implement dealloc in arc?
What is protocol in simple words?
What are the attributes of category?
What does @synchronized() do?
Does objective-c contain private strategies?
What is the main difference between function calls and messages?
How to call a function in objective-c?
What is protocol with example?
How to print string in objective c?
What are the different types of protocols?
Can you differentiate polymorphism from abstraction?
What are nsautoreleasepool?