Created
March 20, 2016 17:09
-
-
Save darthpelo/a864148885a1dab62be7 to your computer and use it in GitHub Desktop.
QuadratTouch search API example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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