Reputation: 3356
I am unsure how to annotate a map in the swift language. I don't know how to create the NSObject class. The following is code I tried but was unable to run:
import Foundation
import MapKit
class MapPin : MKAnnotation
{
var mycoordinate: CLLocationCoordinate2D
var mytitle: String
var mysubtitle: String
func initMapPin (coordinate: CLLocationCoordinate2D!, title: String!, subtitle: String!)
{
mycoordinate = coordinate
mytitle = title
mysubtitle = subtitle
}
}
Upvotes: 37
Views: 19194
Reputation: 94773
This gives you the result:
class MapPin : NSObject, MKAnnotation {
var coordinate: CLLocationCoordinate2D
var title: String?
var subtitle: String?
init(coordinate: CLLocationCoordinate2D, title: String, subtitle: String) {
self.coordinate = coordinate
self.title = title
self.subtitle = subtitle
}
}
Upvotes: 99