title: Property Observer for color change in swift
body: <p>I've successfully created a simple <code>iOS</code> app that will change the background color When I click on the button. But. now the problem is I've no idea on how to implement property observer to print out message to the effect of the color whenever the color has changed.</p>
  
  <p><code>UIColorExtension.swift</code></p>
  
  <pre><code> import UIKit
   extension UIColor {
  
        static var random: UIColor {
          // Seed (only once)
          srand48(Int(arc4random()))
          return UIColor(red: CGFloat(drand48()), green: CGFloat(drand48()), blue: CGFloat(drand48()), alpha: 1.0)
        }
   }
  </code></pre>
  
  <p><code>ViewController.Swift</code></p>
  
  <pre><code> import UIKit
  
   class ViewController: UIViewController {
  
        override func viewDidLoad() {
             super.viewDidLoad()
  
             // apply random color on view did load
             applyRandomColor()
         }
  
  
         @IBAction func btnHandler(_ sender: Any) {
  
             // on each button click, apply random color to view
             applyRandomColor()
         }
  
         func applyRandomColor() {
             view.backgroundColor = UIColor.random
         }
  }
  </code></pre>
  
  <p>Please teach me on how to use property observer to monitor and print the color each time the color is changed as I don't have the slightest idea to do so.</p>