Aditya Shinde Aditya Shinde - 1 year ago 91
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.

Answer Source

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