Short description of the issue:
I have a swift file which is written by others and run smoothly in project A. However I put it into project B, it failed and show me error of
UIImagePicker+Rx.swift:29:16: Ambiguous use of 'delegate'
UIImagePicker+Rx.swift:40:16: Ambiguous use of 'delegate'
Code:
import Foundation
import RxSwift
import RxCocoa
import UIKit
extension Reactive where Base: UIImagePickerController {
/**
Reactive wrapper for `delegate`.
For more information take a look at `DelegateProxyType` protocol documentation.
*/
public var delegate: DelegateProxy {
return RxImagePickerDelegateProxy.proxyForObject(base)
}
/**
Reactive wrapper for `delegate` message.
*/
public var didFinishPickingMediaWithInfo: Observable<[String : AnyObject]> {
return delegate
.methodInvoked(#selector(UIImagePickerControllerDelegate.imagePickerController(_:didFinishPickingMediaWithInfo:)))
.map({ (a) in
return try castOrThrow(Dictionary<String, AnyObject>.self, a[1])
})
}
/**
Reactive wrapper for `delegate` message.
*/
public var didCancel: Observable<()> {
return delegate
.methodInvoked(#selector(UIImagePickerControllerDelegate.imagePickerControllerDidCancel(_:)))
.map {_ in () }
}
}
fileprivate func castOrThrow<T>(_ resultType: T.Type, _ object: Any) throws -> T {
guard let returnValue = object as? T else {
throw RxCocoaError.castingError(object: object, targetType: resultType)
}
return returnValue
}
RxSwift 3.0
Platform/Environment
Xcode version:
8.3.3
Installation method:
I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)
Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)
can you please share the podfile (or list of dependecies) used on Project B? Seems to me you already have another implementation of Reactive<UIImagePickerController>.delegate. I guess removing public var delegate from this file will compile your code.
Thank you so much, it works!
Most helpful comment
can you please share the podfile (or list of dependecies) used on Project B? Seems to me you already have another implementation of
Reactive<UIImagePickerController>.delegate. I guess removingpublic var delegatefrom this file will compile your code.