 //  Copyright © 2017 ZHOU DENGFENG DEREK. All rights reserved.
 //
 
-#if os(iOS)
-import UIKit
-
-public extension UIColor {
-  
-  /// Return a random color
-  static var random: UIColor {
+#if os(macOS)
+import Cocoa
+
+public extension NSColor {
+  static var random: NSColor {
     let red = (0...255).randomElement()!
     let green = (0...255).randomElement()!
     let blue = (0...255).randomElement()!
     
-    return UIColor(red: red, green: green, blue: blue)
+    return NSColor(red: red, green: green, blue: blue)
   }
   
   /// Return components of hue, saturation, brightness, and alpha

    return (hue: h, saturation: s, brightness: b, alpha: a)
  }
  
  
  /// Return RGBA components with CGFloat type (betweem 0.0 and 1.0)
  var rgbaComponents: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {
    var r: CGFloat = 0

    self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: alpha)
  }
  
  /// Create an NSColor object with hexadecimal string.
  /// - Parameters:
  ///   - hexString: hexadecimal string ("#35AF46", "25B767")
  ///   - alpha: opacity value of the color object
