Dmitriy Stupivtsev
Dmitriy Stupivtsev

Reputation: 872

Create ControlProperty for custom UIControl

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.

Upvotes: 5

Views: 3044

Answers (1)

Marcilio Junior
Marcilio Junior

Reputation: 56

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.

Upvotes: 4

Related Questions