Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am fongd on github.
  • I am fonginator (https://keybase.io/fonginator) on keybase.
  • I have a public key ASC7YiF4OQvFzOsTLUzkiedHcen43ntf2G8ZJAZHbVep1go

To claim this, I am signing this object:

@fongd
fongd / result.json
Created September 5, 2017 14:21
JSON result that causes problems with Swift 3.1 - "The data couldn’t be read because it isn’t in the correct format."
{
"messages": [],
"results": [
{
"dataType": "GPFeatureRecordSetLayer",
"paramName": "Route",
"value": {
"displayFieldName": "",
"exceededTransferLimit": false,
"features": [
//
// Reachability.swift
//
import SystemConfiguration
public enum ReachabilityType: CustomStringConvertible {
case WWAN
case WiFi
@fongd
fongd / GooglePlacesSearchModel.swift
Last active August 8, 2016 16:47
Searches are getting executed out of order
class GooglePlacesSearchModel {
static var serialQueue: dispatch_queue_t = dispatch_queue_create("com.example.Search.GooglePlaces", DISPATCH_QUEUE_SERIAL)
[...]
func executeSearch(searchText: String, mapView: GMSMapView?, completion: ([AnyObject]) -> Void) -> () {
// get bounds of mapView to weight our autocomplete query accordingly
var bounds: GMSCoordinateBounds?
if let visibleRegion = mapView?.projection.visibleRegion() {
bounds = GMSCoordinateBounds(coordinate: visibleRegion.farLeft, coordinate: visibleRegion.nearRight)
}
//
// Not sure how to return "data" from getTrailWarnings...
//
func getTrailWarnings() -> Array<Dictionary<String, AnyObject>>? {
let serviceUrl = "http://www.example.com/json"
guard let url = NSURL(string: serviceUrl) else { return nil }
requestTrailWarnings(url) { (data: Array<Dictionary<String, AnyObject>>?) in
return data
}
// set up the data that will be displayed in the info table
let info = [
"sumLengthKm": "Length",
"trailType": "Trail Type",
"activities": "Activities",
"environment": "Environment",
"resources": "Other Resources"
]
for (key, value) in info {
private var _statusCode: Int!
var statusCode: Int! {
get {
return self._statusCode
}
set(newValue) {
if newValue == nil {
self._statusCode = 0
} else {
self._statusCode = newValue
override func viewDidLoad() {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("Search")
self.searchController = UISearchController(searchResultsController: vc)
self.searchView.addSubview(searchController.searchBar)
self.searchController.hidesNavigationBarDuringPresentation = false
self.searchController.dimsBackgroundDuringPresentation = false
self.searchController.searchBar.searchBarStyle = .Minimal
self.searchController.searchBar.sizeToFit()