This file contains 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 showSelectedSearchPlace(selectedPlace :Place){ | |
// to close suggested list when the user selected one | |
searchController.active = false | |
searchController.searchBar.text = selectedPlace.placeName | |
// a red color symbol to mark the place | |
let myMarkerSymbol = AGSSimpleMarkerSymbol() | |
myMarkerSymbol.color = UIColor.redColor() | |
// a point representing x,y data from selctedPlace |
This file contains 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
// Call OneMap's Address Search API to search a location in Singapore | |
func getAddresses(keyWord: String ){ | |
if keyWord != "" { | |
let keyWordEscaped = keyWord.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding) | |
let urlString = "http://www.onemap.sg/API/services.svc/basicSearch?token=qo/s2TnSUmfLz+32CvLC4RMVkzEFYjxqyti1KhByvEacEdMWBpCuSSQ+IFRT84QjGPBCuz/cBom8PfSm3GjEsGc8PkdEEOEr&wc=SEARCHVAL%20LIKE%20%27\(keyWordEscaped!)$%27&otptFlds=CATEGORY&returnGeom=0&nohaxr=10" | |
session.dataTaskWithURL(NSURL(string: urlString)!, completionHandler: { | |
(taskData, taskResponse, taskError) -> Void in | |
var jsonReadError : NSError? |
This file contains 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 updateSearchResultsForSearchController(searchController: UISearchController) { | |
getAddresses(searchController.searchBar.text) | |
} |
This file contains 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
// UITableView delegate protocol methods | |
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { | |
searchController.searchBar.text = searchResults[indexPath.row].placeName | |
showSelectedSearchPlace(searchResults[indexPath.row]) | |
} | |
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { | |
let rowData = searchResults[indexPath.row].placeName | |
let cell = UITableViewCell() | |
cell.textLabel?.text = rowData |
This file contains 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
var searchResults = [Place]() |
This file contains 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
struct Place { | |
var placeName = "" | |
var Category = "" | |
var X = 0.0 | |
var Y = 0.0 | |
} |
This file contains 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
1) End of week checklist @work | |
2) Start of the week checklist @work | |
3) Code review checklist | |
4) Computer maintainance checklist | |
5) Documentation checklist | |
6) House keeping checklist | |
7) Exercise checklist | |
8) Daily habbit checklist | |
9) Effective book reading checklist -> take notes, summarized | |
10) Good coding habbit checklist |
This file contains 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
1) No Agent Strickly Room Share | |
2) Take My Furnitures/TV/Refrigirators/ | |
3) Book Exchange | |
4) Tree Database | |
5) Homeless Society | |
6) Ah Beng Tracker | |
7) Bull Free | |
8) |
This file contains 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
// delegates for AGSMapViewLayer, UISearchController, UITableView | |
class ViewController: UIViewController, AGSMapViewLayerDelegate, | |
UISearchResultsUpdating, UITableViewDelegate, | |
UITableViewDataSource, UISearchControllerDelegate, | |
UISearchBarDelegate { ... |
This file contains 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
// UISearchController Setup | |
searchController = UISearchController(searchResultsController: resultTableViewController) | |
searchController.searchResultsUpdater = self | |
searchController.searchBar.searchBarStyle = UISearchBarStyle.Minimal | |
searchController.hidesNavigationBarDuringPresentation = false | |
navigationItem.titleView = searchController.searchBar |