Reputation: 13
I want to add extra property into MKAnnotation in Swift. Now i can use property like title, subtitle or coordinate. I want to add property for example extraTitle to store some text. I don't know how to write some extension :( Can You help me?
Upvotes: 0
Views: 550
Reputation: 430
MKAnnotation is a protocol. You can define a class which implements the protocol properties, and adds anything extra you want.
class MyAnnotation: NSObject,MKAnnotation {
var coordinate: CLLocationCoordinate2D
var title: String?
var subtitle: String?
var extraTitle: String?
init(coordinate:CLLocationCoordinate2D) {
self.coordinate = coordinate
}
}
Upvotes: 6