Instance Method

dequeueReusableAnnotationViewWithIdentifier:

Returns a reusable annotation view located by its identifier.

Declaration

- (MKAnnotationView *)dequeueReusableAnnotationViewWithIdentifier:(NSString *)identifier;

Parameters

identifier

A string identifying the annotation view to be reused. This string is the same one you specify when initializing the annotation view using the initWithAnnotation:reuseIdentifier: method.

Return Value

An annotation view with the specified identifier, or nil if no such object exists in the reuse queue.

Discussion

For performance reasons, you should generally reuse MKAnnotationView objects in your map views. As annotation views move offscreen, the map view moves them to an internally managed reuse queue. As new annotations move onscreen, and your code is prompted to provide a corresponding annotation view, you should always attempt to dequeue an existing view before creating a new one. Dequeueing saves time and memory during performance-critical operations such as scrolling.

See Also

Creating Annotation Views

- registerClass:forAnnotationViewWithReuseIdentifier:

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

- dequeueReusableAnnotationViewWithIdentifier:forAnnotation:

Returns a reusable annotation view using the specified identifier.

- viewForAnnotation:

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

MKMapViewDefaultAnnotationViewReuseIdentifier

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

MKMapViewDefaultClusterAnnotationViewReuseIdentifier

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software