Home >> ios >> What is the difference between category and extension in Swift in ios

What is the difference between category and extension in Swift in ios

Difference between category and extension?:-

Categories :-Categories provide a way to add methods to a class even if its source code is not available to you. Example: NSString and All methods defined inside a category are also available to the inherited class.

Extensions :- ?Extensions are only possible if the source code is available , because compiler compiles the extension & source code at same time. All properties and methods defined inside a class extension are not even available to inherited class.

Post Your Comment

Next Questions
What is category in Swift
What does extension mean in Swift

Copyright ©2022 coderraj.com. All Rights Reserved.