class Point: NSObject, MKAnnotation {
var id: String?
var title: String?
var coordinate: CLLocationCoordinate2D
var subtitle: String?
init(id: String, dictionary: Dictionary<String, AnyObject>){
self.id = id
if let title = dictionary["title"] as? String {
self.title = title
}
if let subtitle = dictionary["subtitle"] as? String {
self.subtitle = subtitle
}
if let coords = dictionary["coordinates"] as? [String:[String:Double]] {
self.coordinate.latitude = coords.values.first!["latitude"]!
self.coordinate.longitude = coords.values.first!["longitude"]!
}
super.init()
}
/*
init(title: String, subtitle: String, coordinate: CLLocationCoordinate2D){
self.title = title
self.subtitle = subtitle
self.coordinate = coordinate
}*/
。 Firebaseを使用し、データベースの結果が辞書にあるため、私はinitを再設計する必要があります。 それは書いている:プロパティself.coordinateだから暗黙的に生成さでsuper.initコール
タイトルはMKAnnotationプロトコルに従ってオプションでなければならず、座標はオプションではありません。 –
更新された回答を参照してください。 – nhgrif
それはあなたの質問が言っているものにも近くない。 – nhgrif