Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to conform MKAnnotation protocol in Swift

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

import MapKit
import Foundation

class MyAnnotation: NSObject, MKAnnotation
{

}

The same thing is possible with Objective-C.

like image 412
Aditya Avatar asked Mar 27 '15 12:03

Aditya


1 Answers

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
    }
}
like image 190
Abdullah Avatar answered Sep 30 '22 14:09

Abdullah