Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hashable CFString in Swift
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
You can’t perform that action at this time.