Нужна помощь с исправлениям старого кода (Swift GoogleMaps + RX)

Всем привет. Достался старый код на swift 3.2 и старые библиотеки, мне видно не хватает опыта его переписать (обновил библиотеки для перехода на sdk 13 и получил кучу ошибок), вообщем нужна Ваша помощь...

import GoogleMaps
import RxSwift
import RxCocoa

class RxGMSMapViewDelegateProxy: DelegateProxy, GMSMapViewDelegate, DelegateProxyType {

    class func currentDelegateFor(_ object: AnyObject) -> AnyObject? {
        guard let mapView = object as? GMSMapView else { fatalError() }
        return mapView.delegate
    }

    class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) {
        guard let mapView = object as? GMSMapView else { fatalError() }
        mapView.delegate = delegate as? GMSMapViewDelegate
    }

    override class func createProxyForObject(_ object: AnyObject) -> AnyObject { //ошибка
        guard let mapView = object as? GMSMapView else { fatalError() }
        return mapView.createRxDelegateProxy()
    }
//Method does not override any method from its superclass

//предположительно убираем override

    let didTapMarker = PublishSubject<GMSMarker>()

    func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
        didTapMarker.onNext(marker)
        return true
    }

    deinit {
        didTapMarker.onCompleted()
    }
}

extension GMSMapView {

    func createRxDelegateProxy() -> RxGMSMapViewDelegateProxy {
        return RxGMSMapViewDelegateProxy(parentObject: self) //ошибка
//Argument passed to call that takes no arguments
//тут возможно меняем на return RxGMSMapViewDelegateProxy()
    }
}


extension Reactive where Base: GMSMapView {

    var delegate: DelegateProxy<AnyObject, Any> {
        return RxGMSMapViewDelegateProxy.proxyForObject(base) //ошибка
//Type 'RxGMSMapViewDelegateProxy' has no member 'proxyForObject'
//не могу понять на что заменить
    } 

    var idleAtPosition: ControlEvent<GMSCameraPosition> {
        let source = delegate.methodInvoked(#selector(GMSMapViewDelegate.mapView(_:idleAt:)))
            .map { $0[1] as! GMSCameraPosition }

        return ControlEvent(events: source)
    }

    var didTapAtCoordinate: ControlEvent<CLLocationCoordinate2D> {
        let source = delegate.methodInvoked(#selector(GMSMapViewDelegate.mapView(_:didTapAt:)))
            .map { $0[1] as! CLLocationCoordinate2D }

        return ControlEvent(events: source)
    }

    var didTapMarker: ControlEvent<GMSMarker> {
        let source = (delegate as! RxGMSMapViewDelegateProxy).didTapMarker //ошибка
//Cast from 'DelegateProxy<AnyObject, Any>' to unrelated type 'RxGMSMapViewDelegateProxy' always fails

        return ControlEvent(events: source)
    }
}

Подскажите как что исправить.

Спасибо.


Ответы (0 шт):