Create ControlProperty for custom UIControl

3k views Asked by At

Is it possible to make extension of structure Reactive, where base class is my custom control inherited from UIControl?

When I'm trying following code:

extension Reactive where Base: CustomControl {

    public var value: ControlProperty<CGFloat> {

        return CustomControl.rx.value(

            self.base,

            getter: { customControl in
                customControl.customProperty
            },
            setter: { customControl, value in
                customControl.customProperty = value
            }
        )
    }
}

I'm getting following error:

Instance member "value" cannot be used on type 'Reactive<CustomControl>'

I will be grateful if you provide me any explanation.

1

There are 1 answers

0
Marcilio Junior On BEST ANSWER

You can check this link: https://github.com/ReactiveX/RxSwift/issues/991

The method value isn't public so you need to create an public version of that. After that, it'll be possible create the extension for your custom control.