So the name says it all. I am trying to create a class that explicitly inherits from UITextField. This is because I want to make some settings for UITextFields. My main goal is to create a custom initializer for the class, however I ran into a problem doing this.
Here is my code:
import UIKit
class CustomTextField: UITextField {
required init(coder decoder: NSCoder, other:String) {
super.init(coder: decoder)
self.layer.cornerRadius = 15
println("Instantiated")
println(other)
}
}
But the compiler complains 'required' initializer 'init(coder:)' must be provided by subclass of 'UITextField'. Then I continue to apply the proposed fix for the problem and add the following code right below my required initialization code:
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
My code above never prints "Instantiated"
? 2 ( -NSCoder). , (, Java, ).
!
!