Created
October 5, 2015 06:10
-
-
Save jverkoey/afc73edaf0f60fc180ad to your computer and use it in GitHub Desktop.
Hashable CFString in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// Allows Set<CFString> and switch statements of CFString values. | |
extension CFString: Hashable { | |
public var hashValue: Int { return Int(CFHash(self)) } | |
} | |
// Second requirement of conforming to Hashable. | |
public func ==(lhs: CFString, rhs: CFString) -> Bool { | |
return CFStringCompare(lhs, rhs, CFStringCompareFlags()) == .CompareEqualTo | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment