Find answers here
Menu
I want to extend an existing class and add my own methods/functions to it.
// Extend the Int class
extension Int {
// Add a method called 'multiply'
func multiply(x:Int)->Int {
return self*x
}
}
// Now, all our Int's have the extra method
let y = 2.multiply(5)
print(y)
Objective-C to Swift language converter | Visit iSwift Stories
WE CODE.