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
| class CustomAnnotation: MKPointAnnotation { | |
| var color = UIColor.red | |
| var size = CGSize(width: 20, height: 20) | |
| } | |
| class ViewController: UIViewController { | |
| @IBOutlet weak var mapView: MKMapView! | |
| @IBAction func didTapButton(_ sender: UIButton) { |
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 UIColor{ | |
| static func hex(_ hex: String) -> UIColor? { | |
| var string = hex.trimmingCharacters(in: .whitespacesAndNewlines) | |
| if string.hasPrefix("#") { | |
| string.remove(at: string.startIndex) | |
| } | |
| if string.characters.count == 6, let rgbValue = UInt32(string, radix: 16) { | |
| return UIColor( |
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
| class RocketAnnotation: NSObject, MKAnnotation { | |
| dynamic var coordinate: CLLocationCoordinate2D | |
| dynamic var title: String? | |
| dynamic var subtitle: String? | |
| init(coordinate: CLLocationCoordinate2D) { | |
| self.coordinate = coordinate | |
| super.init() | |
| } | |
| } |
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
| // note, P does not declare `greet` as requirement | |
| protocol P {} | |
| // ... but this does provide a "default" implementation | |
| extension P { | |
| func greet() {print("hello")} | |
| } |
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
| class ViewController: UICollectionViewController { | |
| var objects: [CustomObject]! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // add 100 custom objects | |
| objects = ... |
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
| [{ | |
| "DAY": "MONDAY", | |
| "EVENTS": [{ | |
| "TITLE": "TEST DRIVEN DEVELOPMENT", | |
| "SPEAKER": "JASON SHAPIRO", | |
| "TIME": "9:00 AM", | |
| "ROOM": "MATISSE", | |
| "DETAILS": "EXPLORE THE TOPICS AND TOOLS RELATED TO TEST DRIVEN DEVELOPMENT." | |
| }, { | |
| "TITLE": "JAVA TOOLS", |
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
| // | |
| // ViewController.swift | |
| // MyApp4 | |
| // | |
| // Created by Robert Ryan on 3/10/17. | |
| // Copyright © 2017 Robert Ryan. All rights reserved. | |
| // | |
| import UIKit | |
| import Alamofire |
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
| // ViewController.swift | |
| import UIKit | |
| import EventKit | |
| import EventKitUI | |
| class ViewController: UIViewController { | |
| let store = EKEventStore() | |
| @IBAction func didTapButton(_ sender: AnyObject) { |
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
| let runLoop = CFRunLoopGetCurrent() | |
| startAsyncNetworkingStuff() { result in | |
| print(result ?? "No result") | |
| CFRunLoopStop(runLoop) | |
| } | |
| CFRunLoopRun() | |
| print("end") |
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 pillarPlacement(x: CGFloat, y: CGFloat) -> CGPoint { | |
| let pillarX: CGFloat | |
| let pillarY: CGFloat | |
| let random = Int(arc4random_uniform(2)) | |
| if random == 1 { | |
| pillarX = x + 39 | |
| pillarY = y - 29 | |
| } else { | |
| pillarX = x - 40 |