Subclassing error MKAnnation, conforms to protocol

I looked at other codes and snippets from other questions in the subclass. All I am trying to do is subclass MKAnnotation. I am using Xcode 6.3. This code works for my friend, but not mine.

I am getting "Annotation" type does not match protocol "MKAnnotation" error

import Foundation
import MapKit
import UIKit

class Annotation : NSObject, MKAnnotation {
    var location: CLLocationCoordinate2D
    var title: String
    var subtitle: String

   init(location: CLLocationCoordinate2D, title: String, subtitle: String) {
      self.location = location
      self.title = title
      self.subtitle = subtitle
}
}

      

+3


source to share


1 answer


You are not fully compliant with the protocol MKAnnotation

. In addition to the title

and properties subtitle

(which are actually optional), you need to expose the property coordinate

(see here ).



Your location

(which is CLLocationCoordinate2D

) will do the trick if you just rename it.

+3


source







All Articles