Aditya Shinde Aditya Shinde - 2 months ago 25
iOS Question

Unable to conform MKAnnotation protocol in Swift

When I try to conform

protocol it throw error my class does not conform to protocol
. I am using the following code

import MapKit
import Foundation

class MyAnnotation: NSObject, MKAnnotation


The same thing is possible with Objective-C.


You need to implement following required property in the calls:

class MyAnnotation: NSObject, MKAnnotation {
    var myCoordinate: CLLocationCoordinate2D

    init(myCoordinate: CLLocationCoordinate2D) {
        self.myCoordinate = myCoordinate

    var coordinate: CLLocationCoordinate2D { 
        return myCoordinate