Trong Swift, bạn phải thực hiện tất cả các biến và phương pháp của một giao thức không bắt buộc theo thứ tự để phù hợp với một giao thức. Ngay bây giờ, lớp học của bạn trống, có nghĩa là bây giờ nó không phù hợp với giao thức thw MKAnnotation
. Nếu bạn nhìn vào tờ khai của MKAnnotation
:
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)
}
bạn có thể thấy, rằng nếu bạn thực hiện ít nhất là biến coordinate
, sau đó bạn phù hợp với các giao thức.
Nguồn
2015-03-27 12:30:19
Check-out này liên kết, các cùng một vấn đề http://stackoverflow.com/questions/24233873/mkannotation-swift –