I want to create category of my existing swift class, but there is no option in IDE to do so.
Any idea if category exists in swift project? Or how to achieve similar functionality in swift project?
In Swift, you can use Extensions
to add new functionality to existing classes, structs and enumeration types.
They differ from Objective-C categories in a few ways, mainly:
As it stands today, Extensions can:
The basic syntax to declare an extension is as follows:
extension SomeType {
// new functionality to add to SomeType goes here
}
Check Apple's documentation for more information on how to use Extensions in Swift.