I have created a custom UITextField like this
import Foundation
import UIKit
class NoZeroTextField: UITextField, UITextFieldDelegate {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.delegate = self
}
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
if (string == "0" ) {
//ignore input
return false
}
return true
}
}
I am trying to write unit test for the class but the problem is with passing NSCoder instance to the constructor. I cannot instantiate it or set it to nil. How can I unit-test this class?
I figured this out. Class under test:
The test itself: