Concepts
/
Building Search UI
/
Algolia Places
May. 10, 2019
Algolia Places
On this page
Using Places on iOS
You can use Algolia Places on iOS by instantiating a PlacesClient
and using it for search:
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Create an unauthenticated client:
var places = PlacesClient()
// or provide credentials to create an authenticated, full-fledged client:
var places = PlacesClient(appID: appID, apiKey: apiKey)
// Create your query and set its parameters for your search
let query = PlacesQuery()
query.query = "Paris"
query.type = .city
query.hitsPerPage = 10
query.aroundLatLngViaIP = false
query.aroundLatLng = LatLng(lat: 32.7767, lng: -96.7970) // Dallas, TX, USA
query.language = "en"
query.countries = ["fr", "us"]
// Search Places
places.search(query) { (content, error) in
if let error = error {
// do something with error
} else if let content = content {
// do something with content["hits"] to access the hits
}
}