     public func getColors(scaleDownSize: CGSize = CGSize.zero) -> UIImageColors {
         
         var scaleDownSize = scaleDownSize
+        
         if scaleDownSize == CGSize.zero {
             let ratio = self.size.width/self.size.height
             let r_width: CGFloat = 250
-            scaleDownSize = CGSizeMake(r_width, r_width/ratio)
+            scaleDownSize = CGSize(width: r_width, height: r_width/ratio)
         }
         
         var result = UIImageColors()
         
-        let cgImage = self.resizeForUIImageColors(scaleDownSize).CGImage!
-        let width = CGImageGetWidth(cgImage)
-        let height = CGImageGetHeight(cgImage)
+        let cgImage = self.resizeForUIImageColors(newSize: scaleDownSize).cgImage!
+        let width = cgImage.width
+        let height = cgImage.height
         
         let bytesPerPixel: Int = 4
         let bytesPerRow: Int = width * bytesPerPixel
         let bitsPerComponent: Int = 8
         let randomColorsThreshold = Int(CGFloat(height)*0.01)
-        let sortedColorComparator: NSComparator = { (main, other) -> NSComparisonResult in
+        let sortedColorComparator: Comparator = { (main, other) -> ComparisonResult in
             let m = main as! PCCountedColor, o = other as! PCCountedColor
             if m.count < o.count {
-                return NSComparisonResult.OrderedDescending
+                return ComparisonResult.orderedDescending
             } else if m.count == o.count {
-                return NSComparisonResult.OrderedSame
+                return ComparisonResult.orderedSame
             } else {
-                return NSComparisonResult.OrderedAscending
+                return ComparisonResult.orderedAscending
             }
         }
         let blackColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)

        }
    }
    
    private func isContrastingColor(compareColor: UIColor) -> Bool {
        let bg = CGColorGetComponents(self.CGColor)
        let fg = CGColorGetComponents(compareColor.CGColor)
        
        let bgLum = 0.2126 * bg[0] + 0.7152 * bg[1] + 0.0722 * bg[2]
        let fgLum = 0.2126 * fg[0] + 0.7152 * fg[1] + 0.0722 * fg[2]

        if result.detailColor == nil {
            result.detailColor = isDarkBackgound ? whiteColor:blackColor
        }
        
        return result
    }
}

extension CGColor {
    var components:[CGFloat] {
        get {
            var red = CGFloat()
            var green = CGFloat()
            var blue = CGFloat()
            var alpha = CGFloat()
            UIColor(cgColor: self).getRed(&red, green: &green, blue: &blue, alpha: &alpha)
            return [red,green,blue,alpha]
        }
    }
}
