Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import Foundation
  2. import UIKit
  3.  
  4. struct Note {
  5.  
  6. enum Importance: UInt {
  7. case unimportant = 0, normal, important
  8. }
  9.  
  10. let uid: String
  11. var title: String
  12. var content: String
  13. var color: UIColor
  14. var importance: Importance
  15. var selfDestructDate: Date?
  16.  
  17. init(uid: String = UUID().uuidString, title: String, content: String, color: UIColor = .white, importance: Importance, destructDate: Date? = nil) {
  18.  
  19. self.uid = uid
  20. self.title = title
  21. self.content = content
  22. self.importance = importance
  23. self.color = color
  24. selfDestructDate = destructDate
  25. }
  26. }
  27.  
  28. var a = Note(title: "Note 1", content: "Text 1", importance: .normal)
  29. var b = a
  30.  
  31.  
  32. DispatchQueue.global().async {
  33. a.color = .red
  34. a.title = "Note changed 1"
  35. a.content = "Text changed 1"
  36. a.importance = .important
  37. a.selfDestructDate = Date()
  38.  
  39. DispatchQueue.main.async {
  40. sleep(2)
  41. print(">> a \(a)")
  42. }
  43. }
  44.  
  45.  
  46. DispatchQueue.global(qos: .utility).async {
  47. sleep(3)
  48. print(">> utility: b \(b)")
  49. }
  50.  
  51. DispatchQueue.global(qos: .background).async {
  52. print(">> background: b \(b)")
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement