Skip to content

Commit

Permalink
Remove description and debugDescription
Browse files Browse the repository at this point in the history
Extensions can add new functionality to a type, but they cannot
override existing functionality.
  • Loading branch information
yeahdongcn committed Sep 19, 2016
1 parent 09db793 commit 1d44ac3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
8 changes: 0 additions & 8 deletions HEXColor/UIColorExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,4 @@ extension UIColor {
return String(format: "#%02X%02X%02X", Int(r * 255), Int(g * 255), Int(b * 255))
}
}

public override var description: String {
return self.hexString(true)
}

public override var debugDescription: String {
return self.hexString(true)
}
}
22 changes: 5 additions & 17 deletions HEXColorTests/HEXColorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,21 +293,14 @@ class HEXColorTests: XCTestCase {
XCTAssertEqual("#AABBCCDD", hexColor.hexString(true))
}

// MARK: - Desc

func testDesc() {
let color = UIColor(red: CGFloat(0x22 / 255.0), green: CGFloat(0x44 / 255.0), blue: CGFloat(0x66 / 255.0), alpha: CGFloat(0x88 / 255.0))
XCTAssertEqual("#22446688", color.description)
XCTAssertEqual("#22446688", color.debugDescription)

let hexColor = UIColor(rgba: "#AABBCCDD", defaultColor: UIColor.yellowColor());
XCTAssertEqual("#AABBCCDD", hexColor.description)
XCTAssertEqual("#AABBCCDD", hexColor.debugDescription)
}

}

extension UIColor {
private func toUInt8(value: CGFloat) -> UInt8 {
let multiplier = CGFloat(255)
return UInt8(value * multiplier)
}

private func rgba() -> (red: UInt8, green: UInt8, blue: UInt8, alpha: UInt8) {
var red: CGFloat = 0
var green: CGFloat = 0
Expand All @@ -317,8 +310,3 @@ extension UIColor {
return (toUInt8(red), toUInt8(green), toUInt8(blue), toUInt8(alpha))
}
}

private func toUInt8(value: CGFloat) -> UInt8 {
let multiplier = CGFloat(255)
return UInt8(value * multiplier)
}

0 comments on commit 1d44ac3

Please sign in to comment.