Skip to content

Instantly share code, notes, and snippets.

@yoichitgy
Created September 16, 2017 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoichitgy/933eb2a7238740efdd0b305a968a359c to your computer and use it in GitHub Desktop.
Save yoichitgy/933eb2a7238740efdd0b305a968a359c to your computer and use it in GitHub Desktop.
iOSDC JAPAN 2017 Demo - ViewController.swift
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