In Swift, können Sie sich alle nicht-optionale Variablen und Methoden eines Protokolls, um ein Protokoll zu entsprechen umsetzen müssen. Im Moment ist Ihre Klasse leer, was bedeutet, dass sie nicht konform ist mit dem Protokoll MKAnnotation
. Wenn man sich die declaraton von MKAnnotation
aussehen:
protocol MKAnnotation : NSObjectProtocol {
// Center latitude and longitude of the annotation view.
// The implementation of this property must be KVO compliant.
var coordinate: CLLocationCoordinate2D { get }
// Title and subtitle for use by selection UI.
optional var title: String! { get }
optional var subtitle: String! { get }
// Called as a result of dragging an annotation view.
@availability(OSX, introduced=10.9)
optional func setCoordinate(newCoordinate: CLLocationCoordinate2D)
}
können Sie sehen, dass, wenn Sie zumindest den coordinate
Variable implementieren, dann entsprechen Sie das Protokoll.
prüfen diese Links aus, die gleiche Ausgabe http://stackoverflow.com/questions/24233873/mkannotation-swift –