Skip to content

Instantly share code, notes, and snippets.

@darthpelo
Created March 20, 2016 17:09
Show Gist options
  • Select an option

  • Save darthpelo/a864148885a1dab62be7 to your computer and use it in GitHub Desktop.

Select an option

Save darthpelo/a864148885a1dab62be7 to your computer and use it in GitHub Desktop.
QuadratTouch search API example
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let location = locations.first {
print("Found user's location: \(location)")
let session = Session.sharedSession()
var parameters = location.parameters()
let cat = Constants().categoryID() ?? ""
parameters += [Parameter.categoryId:cat]
parameters += [Parameter.intent:"browse"]
parameters += [Parameter.radius:"800"]
parameters += [Parameter.limit:"20"]
let searchTask = session.venues.search(parameters) { (result) -> Void in
if let response = result.response,
let venues = response["venues"] {
self.shopsList.removeAll()
for i in 0..<venues.count {
if let dict = venues[i] as? NSDictionary,
let name = dict["name"] as? String,
let location = dict["location"] as? NSDictionary,
let address = location["address"] as? String {
if !name.containsString("Coffeeshop") {
let shop = NearShop(shopName: name, address: address)
self.shopsList.append(shop)
}
}
}
self.tableView.reloadData()
self.activityIndicator.stopAnimating()
}
}
searchTask.start()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment