Created
September 16, 2017 06:29
-
-
Save yoichitgy/933eb2a7238740efdd0b305a968a359c to your computer and use it in GitHub Desktop.
iOSDC JAPAN 2017 Demo - ViewController.swift
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 UIKit | |
class ViewController: UIViewController { | |
private var count = 0 | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
Log.info(message: "viewDidLoad") | |
Log.info(message: "API: GET /some/values") | |
Log.info(message: "User did something.") | |
} | |
@IBAction func infoTapped(_ sender: Any) { | |
count += 1 | |
Log.info(message: "Info tapped \(count)") | |
} | |
@IBAction func errorTapped(_ sender: Any) { | |
let fakeUrl = URL(string: "https://fake.google.com")! | |
let request = URLRequest(url: fakeUrl) | |
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in | |
if let error = error { | |
Log.error(error: error) | |
return | |
} | |
// Do something | |
} | |
task.resume() | |
} | |
@IBAction func fatalTapped(_ sender: Any) { | |
guard count < 0 else { | |
Log.fatal(message: "count value is unexpected.") | |
return | |
} | |
// Do something | |
} | |
@IBAction func crashTapped(_ sender: Any) { | |
let nilValue: String? = nil | |
print(nilValue!) // Crash | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment