【发布时间】:2016-06-11 01:30:26
【问题描述】:
所以我正在使用一个使用 MKMapView 的 Objective-C 库。
所以有一个类:
@interface BSWeatherMapView : MKMapView
/** The receiver’s delegate. */
@property (nonatomic, weak) id<BSWeatherMapViewDelegate> delegate;
它的协议是用这个方法定义的:
@protocol BSWeatherMapViewDelegate<MKMapViewDelegate>
@optional
- (MKAnnotationView *)mapView:(BSWeatherMapView *)mapView viewForAnnotation:(id<MKAnnotation >)annotation;
我的 swift 类有一个扩展,它执行以下操作:
extension ViewController : BSWeatherMapViewDelegate {
func mapView(mapView: BSWeatherMapView!, viewForAnnotation annotation: AnyObject) -> MKAnnotationView! {}
}
当我这样做时,我收到以下错误:
方法mapView(_:viewForAnnotation:)提供的Objective-C方法mapView:viewForAnnotation:与协议MKMapViewDelegate中的可选要求方法mapView(_:viewForAnnotation:)冲突
我不知道如何通过这个...有人吗?
谢谢,
【问题讨论】:
-
不幸的是,这在 Objective C 中是合法的。有没有办法解决这个问题?我们最初的应用程序是在 Objective-C 中的,这一切都很好。
-
那么有没有办法让我告诉它这是我要处理的一个,而另一个可以忽略?
标签: objective-c swift delegates protocols