Adding initializers using extensions in Swift
Forums:
private class Size {
var width: Int = 0
var height: Int = 0
}
extension Size {
convenience init(width: Int, height: Int) {
self.init()
self.width = width
self.height = height
}
}
let size = Size(width: 4, height: 5)
- Log in to post comments