Instance Method


Registers an annotation view class that the map can create automatically.


func register(_ viewClass: AnyClass?, forAnnotationViewWithReuseIdentifier identifier: String)



The class of an annotation view that you use in your map. The class must be a subclass of MKAnnotationView.


The reuse identifier to associate with the specified class. This parameter must not be nil or an empty string.


Use this method to register one or more views that you use to display annotations on your map. Register your classes before adding any annotations to the map.

When you register an annotation view class using this method, the dequeueReusableAnnotationView(withIdentifier:for:) method uses the provided identifier to create the view that you registered. It creates a new view only if an existing view is not available for reuse.

See Also

Creating Annotation Views

func dequeueReusableAnnotationView(withIdentifier: String, for: MKAnnotation) -> MKAnnotationView

Returns a reusable annotation view using the specified identifier.

func dequeueReusableAnnotationView(withIdentifier: String) -> MKAnnotationView?

Returns a reusable annotation view located by its identifier.

func view(for: MKAnnotation) -> MKAnnotationView?

Returns the annotation view associated with the specified annotation object, if any.

let MKMapViewDefaultAnnotationViewReuseIdentifier: String

The default reuse identifier for your map's annotation views.

let MKMapViewDefaultClusterAnnotationViewReuseIdentifier: String

The default reuse identifier for the annotation view representing a cluster of annotations.