A utility object for generating a list of completion strings based on a partial search string that you provide.
- iOS 9.3+
- macOS 10.11.4+
- Mac Catalyst 13.0+
- tvOS 9.2+
You use an
MKLocal object to retrieve auto-complete suggestions for your own map-based search controls. As the user types text, you feed the current text string into the search completer object, which delivers possible string completions that match locations or points of interest.
You create and configure
MKLocal objects yourself. You must always assign a delegate object to the search completer so that you can receive the search results that it generates. You should also specify a search region to restrict results to a designated area.Listing 1 shows a simple example of a view controller that stores the
MKLocal object in a property. The view controller itself acts as the delegate for the completer and the view controller uses the region associated with an
MKMap object that is part of the view controller’s interface. Completer objects are long-lived objects, so you can store strong references to them and reuse them later in your code.
Update the value of the completer’s
query property to begin a search query. You can update this property in real time as the user types new characters into a text field because the completer object waits a short amount of time for the query string to stabilize. When modifications to the query strong stop, the completer initiates a new search and returns the results to your delegate as an array of