Slide 147
Slide 147 text
import UIKit
class ExampleViewController: UIViewController {
@IBOutlet weak var label: UILabel!
@IBAction
func buttonTapped(_ sender: Any) {
APIClient.shared.get(type: User.self, url: URLs.getSomething) { [weak self] (user, error) in
guard let `self` = self else { return }
if let error = error {
dump(error)
let alertViewController = UIAlertController(
title: "Τϥʔ͕ൃੜ͠·ͨ͠",
message: nil,
preferredStyle: .alert
)
alertViewController.addAction(UIAlertAction(title: "OK", style: .default))
self.present(alertViewController, animated: true)
return
}
self.label.text = "Hello, \(user!.name)!"
}
}
}
ಈ࡞֬ೝͷࣗಈԽ͕͔ͳΓ͍͠ྫ