我查看了子类化中其他堆栈溢出问题的其他代码和片段。我试图做的只是子类MKAnnotation。我正在使用Xcode 6.3。这段代码适用于我的朋友但不是我的。
我收到 类型'注释'不符合协议' MKAnnotation' 错误
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
}
}
答案 0 :(得分:3)
您并未完全符合MKAnnotation
协议。除了title
& subtitle
属性(实际上是可选的),您需要公开coordinate
属性(请参阅here)。
如果您只是重命名,那么location
(CLLocationCoordinate2D
)将会成功。