Skip to content

Instantly share code, notes, and snippets.

@DonMag
Created February 15, 2017 22:13
Show Gist options
  • Select an option

  • Save DonMag/80c7c68229ef0c190ee02579e485f23e to your computer and use it in GitHub Desktop.

Select an option

Save DonMag/80c7c68229ef0c190ee02579e485f23e to your computer and use it in GitHub Desktop.
//----------------------------------------------------------------------------------
// new class
// MyMKPointAnnotation.swift
// ChatMap
//
// Created by Don Mag on 2/15/17.
// Copyright © 2017 Chris. All rights reserved.
//
import Foundation
import MapKit
class MyMKPointAnnotation: MKPointAnnotation {
public var myTag: Int = 0
}
//----------------------------------------------------------------------------------
// in ViewController.swift
// in func updateUI()
// change
// let annotation = MKPointAnnotation()
// to
let annotation = MyMKPointAnnotation()
annotation.myTag = i
// in func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
// change
// var annotationView = MKPinAnnotationView()
// annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "\(value)")
// to
let myAnnot = annotation as! MyMKPointAnnotation
let annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "\(myAnnot.myTag)")
// see if that helps...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment