0
import MapKit
import UIKit
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]] {
var latitude = coords.values.first!["latitude"]!
var longitude = coords.values.first!["longitude"]!
var location = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
self.coordinate = location
}
}
エラー:暗黙的に生成されたsuper.init呼び出しでプロパティself.coordinateが初期化されませんでした。カスタムMKAnnotation辞書入力(CLLocationCoordinate2d)
これを解決する方法はありますか?
ありがとうございました。
最初の行は「でsuper.init()」である必要があります[それはエラーのメッセージがあなたを言っているまさにである] –
私はこの行を追加していますが、同じエラーを書き込みます。プロパティself.coordinateは初期化されていませんat super.init call –
'coordinate'はオプションではないので、コントロールフローの各ブランチに対して初期化する必要があります。 – Moritz