var mapViewDelegate: AnyObject?
init(mapView: AGSMapView, mapViewDelegate: AnyObject) {
self.mapView = mapView
self.mapViewDelegate = mapViewDelegate
super.init()
}
mapView?.touchDelegate = mapViewDelegate
mapView?.layerDelegate = mapViewDelegate
然后:
无法指定类型' AnyObject的值?'输入' AGSMapViewTouchDelegate!'
我该怎么办?谢谢你的所有答案
答案 0 :(得分:0)
var mapViewDelegate: AnyObject?
不应该是这样。
它应属于议定书的所有类型。不是任何对象。
就像我有一个名为AllowNotificationDelegate的协议。 所以我的委托变量定义为
weak var allowNotificationDelegate: AllowNotificationDelegate?
AllowNotificationDelegate的类型。
所以你应该写
weak var mapViewDelegate: AGSMapViewTouchDelegate?