Documentation

Initialization

The TTL2Search class encapsulates a connection bridge to the TomTom Search API service.

SWIFT
OBJECTIVEC
let search = TTSearch(key: Key.Search)
self.search = [[TTSearch alloc] initWithKey:Key.Search];

Call the searchWithQuery method to perform a search. The call uses the TTL2SearchQuery parameter from the TTL2Search class. Use the builder design pattern to simplify construction of the TTL2SearchQuery.

The API reference contains a detailed specification of the search objects and options. It also includes a number of functional examples to illustrate different uses cases.

Search result delegate

Every search Request requires a TTL2SearchDelegate object. The object asynchronously calls one of two methods when the search result is ready:

  1. If the search query is successful, the first method returns an array of search results.
  2. If the query fails, the second method returns an error code and an error message.
SWIFT
OBJECTIVEC
1func search(_: TTSearch, completedWith response: TTSearchResponse) {
2 progress.hide()
3 displayResults(response.results)
4}
5func search(_: TTSearch, failedWithError error: TTResponseError) {
6 handleError(error)
7}
1- (void)search:(TTSearch *)search completedWithResponse:(TTSearchResponse *)response {
2 [self.progress hide];
3 [self displayResults:response.results];
4}
5- (void)search:(TTSearch *)search failedWithError:(TTResponseError *)error {
6 [self handleError:error];
7}