Guest User

Untitled

a guest
Oct 11th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. @IBOutlet weak var messageLabel: UILabel!
  2.  
  3. @IBOutlet weak var activityIndicator: UIActivityIndicatorView!
  4.  
  5. override func viewDidLoad() {
  6. super.viewDidLoad()
  7.  
  8. messageLabel.text = ""
  9. }
  10.  
  11. @IBAction func startTestButtonPress(_ sender: UIButton) {
  12.  
  13. messageLabel.text = "Starting test"
  14.  
  15. activityIndicator.startAnimating()
  16.  
  17. DispatchQueue.global(qos: .userInitiated).async { [weak self] in
  18.  
  19. Thread.sleep(until: Date(timeIntervalSinceNow: 5.0))
  20.  
  21. DispatchQueue.main.async {
  22.  
  23. self?.activityIndicator.stopAnimating()
  24.  
  25. self?.messageLabel.text = "Test completed"
  26. }
  27. }
  28. }
Add Comment
Please, Sign In to add comment