Returns a reusable annotation view located by its identifier.
SDKs
- iOS 3.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.2+
Framework
- Map
Kit
Declaration
func dequeueReusableAnnotationView(withIdentifier identifier: String) -> MKAnnotation View?
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
init(annotation:
method.reuse Identifier:)
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 MKAnnotation
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.