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 mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { | |
| // 1 | |
| if let item = annotation as? MapItem { | |
| // 2 | |
| let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "mapItem") | |
| ?? MKAnnotationView(annotation: annotation, reuseIdentifier: "mapItem") | |
| annotationView.annotation = item | |
| annotationView.image = UIImage(named: "annotation") | |
| // 3 |
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
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| mapView.delegate = self | |
| for randCoordinate in makeRandomCoordinates(in: mapView.region) { | |
| let annotation = MapItem(coordinate: randCoordinate) | |
| mapView.addAnnotation(annotation) | |
| } | |
| } |
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
| /// Using `blockURLComponent`, requests relenvant data from FRING API for the given blocks. Before | |
| /// requesting, it will check the `fetchedBlockIds` set, attempting to avoid requesting duplicate | |
| /// information. After data is fetched, `processOperation` will be called. | |
| func requestData(for blockIds: [(MKShape, String)]) -> Observable<[[String: Any]]> { | |
| assert(parse != nil, "parse closure was never set; this is a requirement of use") | |
| let rv = PublishSubject<[[String: Any]]>() | |
| // bail if we already have all block data | |
| let filteredBlockIds = blockIds |
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
| #!/bin/bash | |
| for i in *; do | |
| if [[ $i == *.xcworkspace ]]; then | |
| echo "found $i; opening" | |
| open $i | |
| exit 0 | |
| fi | |
| done |
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
| import CoreLocation | |
| import Darwin | |
| private enum EarthUnits: Double { | |
| case ImperialRadius = 3961.0 | |
| case MetricRadius = 6373.0 | |
| } | |
| postfix operator ° {} | |
| postfix func °(degrees: Double) -> Double {return degrees * M_PI / 180.0} |
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
| struct ClimbingGear: SequenceType { | |
| let brand: String | |
| let gear: [String] | |
| typealias Generator = AnyGenerator<String> | |
| func generate() -> Generator { | |
| var i = 0 | |
| return anyGenerator { | |
| if i < self.gear.count { |
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
| extension UIView { | |
| func replaceWithNewView(newView: UIView, withAnimation animated: Bool, completion: ((Bool) -> Void)?) { | |
| if let oldSuperview = self.superview { | |
| newView.frame = self.frame | |
| newView.transform = CGAffineTransformMakeScale(0.1, 0.1) | |
| oldSuperview.addSubview(newView) | |
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
| //test gist |