在Swift 1.2中我有这个:
List<Developer> devs = em
.createQuery("select c from Developer c ", Developer.class)
.setLockMode(LockModeType.PESSIMISTIC_WRITE).getResultList();
for (Developer developer : devs) {
developer.setName("asdf");
}
List<Developer> devs2 = em
.createQuery("select c from Developer c ", Developer.class)
.setLockMode(LockModeType.PESSIMISTIC_WRITE).getResultList();
for (Developer developer : devs2) {
developer.setName("1234");
}
Swift 2已将class UVC: NSViewController, MKMapViewDelegate {
// ...
// **************************************
// MARK: MapView Delegate
// **************************************
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer! {
if overlay is OSGBTiles {
return OSGBTilesRenderer(tileOverlay: overlay as! OSGBTiles)
} else if overlay is ESRI {
return ESRIRenderer(shapeFileOverlay: overlay as! ESRI)
} else if overlay is MKTileOverlay {
return MKTileOverlayRenderer(overlay: overlay)
} else {
print("Unknown overlay")
}
return nil
}
}
的定义更改为现在返回mapView:rendererForOverlay
而不是MKOverlayRenderer
,现在不允许我以MKOverlayRenderer!
(不出所料)返回nil
1}}不是MKOverlayRenderer
。但是,文档(在Xcode 7中)仍然说:
返回值
呈现指定叠加层时要使用的渲染器 在地图上。如果返回nil,则不会为指定的内容绘制内容 叠加对象。
如果通过我无法识别的叠加层,我应该返回什么?
答案 0 :(得分:2)
根据最新的MKMapView.h,新的函数声明现在是:
// Current renderer for overlay; returns nil if the overlay is not shown.
@available(iOS 7.0, *)
func rendererForOverlay(overlay: MKOverlay) -> MKOverlayRenderer?