adspace


What is category and class extension? How these differ?

Answer Posted / Pramd Kumar

A category in Objective-C is a way of extending an existing class by adding new methods, properties, or categories (other categories). Categories are declared using the @category directive, which specifies the name of the category and the name of the original class that it extends. Categories can be used to add functionality to existing classes without modifying their source code.nnClass extensions in Swift are similar to categories in Objective-C, but they are a part of the source file for the class they extend. Class extensions allow you to add additional properties and methods that are not exposed to the public interface of the class. Unlike categories, class extensions do not affect the behavior of existing instances of the class.nnThe main difference between categories and class extensions is that categories can be used with any existing class, while class extensions must be defined within the source file for the class they extend.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain parent-child context setup. How does it work? What are the advantages?

875


What is latest version of ios?

867


Why do all model object attributes get marked with @dynamic and not synthesised? What does @dynamic mean?

850


What is dependency management tools?

877


In a single model, can I have few entities in one sqlite db file and remaining in another sqlite db file?

991


What are the different store migration options? How do they work?

879


Why do all model object attributes get marked with @dynamic and not synthesised?

976


What is nsmanagedobjectcontext? What are the different concurrency types? Explain them.

832


What's the latest version of ios?

977


What is latest ios version?

1003


What is the purpose of reuseidentifier?

920


How to handle concurrency problems in core data?

1017


What are transient properties?

925


What is latest xcode version?

920