Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create ControlProperty for custom UIControl

Tags:

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.

like image 507
Dmitriy Stupivtsev Avatar asked Dec 27 '16 09:12

Dmitriy Stupivtsev


1 Answers

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.

like image 184
Marcilio Junior Avatar answered Sep 24 '22 16:09

Marcilio Junior