Advertisement
wpl36

Untitled

Jun 27th, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1.  
  2.  
  3. import UIKit
  4.  
  5. class MainViewController: UIViewController {
  6.  
  7.  
  8. class User {
  9. let name: String
  10.  
  11. init(name: String) {
  12. self.name = name
  13. print("User \(name) was initialized")
  14. }
  15.  
  16.  
  17.  
  18. class Phone {
  19. let model: String
  20. var owner: User?
  21.  
  22. init(model: String) {
  23. self.model = model
  24. print("Phone \(model) was initialized")
  25. }
  26.  
  27. deinit {
  28. print("Deallocating phone named: \(model)")
  29. }
  30. }
  31. deinit {
  32. print("Deallocating user named: \(name)")
  33. }
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. func runScenario() {
  42. let user = User(name: "John")
  43. let phone = Phon
  44. }
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. override func viewDidLoad() {
  53. super.viewDidLoad()
  54. runScenario()
  55. }
  56.  
  57. }
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement