Here is my code to set up Custom Property in RXSwift for the UIControl but same I am not able to get in Combine although I have taken the CombineCocoa Reference.
public class OTPFieldView: UIControl, InputFieldView {
public typealias FieldType = TOTPField
public weak var field: TOTPField?
}
extension Reactive where Base: InputFieldView, Base: UIControl, Base.FieldType.FieldValueType == String {
public var text: ControlProperty<String?> {
return base.rx.controlProperty(editingEvents: [.valueChanged], getter: { fieldView in
return fieldView.field?.value
}, setter: { fieldView, value in
fieldView.updateValue(value, isObfuscated: false, shouldSendActions: true, animated: true)
})
}
}
Public class Controller{
var fieldView:OTPFieldView!
fieldView.rx.text /// GETTING TRIGGER
}
But same thing when I am trying using combine publisher, getting following error below. UIContol does not have text proerty.
Here is my combine code.
public extension InputFieldView where Self:UIControl,Self.FieldType.FieldValueType == String {
var textPublisher: AnyPublisher<String?, Never> {
Publishers.ControlProperty(control: self, events: .defaultValueEvents, keyPath: \.text)
.eraseToAnyPublisher()
} // getting error \.text Property