ios - How can I fix my MKOverlayRenderer now that I'm using Swift 2.0? -


so when using swift 1.2, function worked fine , gave me functionality needed.

func mapview(mapview: mkmapview, rendererforoverlay overlay: mkoverlay) -> mkoverlayrenderer {      if overlay mkpolyline {         let pr = mkpolylinerenderer(overlay: overlay)         pr.strokecolor = self.lightblue         pr.linewidth = 14         return pr     } //i error here, because need return     } 

now, error saying "missing return in function expected return 'mkoverlayrenderer'".

is still how method used? can remedy this?

func mapview(mapview: mkmapview, rendererforoverlay overlay: mkoverlay) -> mkoverlayrenderer 

will called each overlay add instance of mkmapview.

if add mkpolyline mapview, can sure when delegate function called, overlay parameter of type mkpolyline. since case, there no reason check if overlay parameter instance of mkpolyline if overlay mkpolyline. can this:

func mapview(mapview: mkmapview, rendererforoverlay overlay: mkoverlay) -> mkoverlayrenderer {     let pr = mkpolylinerenderer(overlay: overlay)     pr.strokecolor = self.lightblue     pr.linewidth = 14     return pr } 

if ever add different type of overlay mkmapview, can this:

if overlay mkpolyline {     // return renderer mkpolyline overlay     return mkpolylinerenderer } else {     // handle different type of overlay...     return othertypeofoverlayrenderer } 

the swift compiler intelligent enough infer if/else block returned.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -