にカスタム注釈をキャストMKAnnotationやCKAnnotationの一部ではないMyAnnotationsのプロパティは、サイズや所有者のように私は以下のようにします。スウィフトは、私は、アノテーションクラスター(<a href="https://github.com/hulab/ClusterKit" rel="nofollow noreferrer">Cluster</a>この1)を使用私のアプリではMKAnnotation
let MyAnnotations = annotation as! MyAnnotations
let size = MyAnnotations.size
i get error: Could not cast value of type 'NSKVONotifying_CKCluster' (0x60000011dc70) to 'app.MyAnnotations'
これらのプロパティにアクセスする方法はありますか?
EDIT:
let annotation = MyAnnotations(coordinate: location)
annotation.coordinate = location
annotation.title = name
annotation.subtitle = specie
annotation.size = size
annotation.owner = owner
annotation.user = user
annotation.image = pictureurl
annotation.latLoc = lat
annotation.lonLoc = lon
annotation.itemId = itemId
あなたのコードに誤ってタイプミスがあります:あなたは変数 'MyAnnotations'を呼び出してから、' MyAnnotation.size'を呼び出そうとします。また、変数にクラス名と同じ名前を付け、適切なSwift命名規則(クラス: 'MyAnnotations'、変数:' myAnnotation')を使用します。 –
私はタイプミスを編集しました。(コピーエラー) – HaVaNa7
注釈を定義するコードを表示してください。アノテーションは 'CKCluster'型のようです。サブクラスではないので、明らかに' MyAnnotations'にキャストできません。 –