Created
April 23, 2015 08:05
-
-
Save odrobnik/a95d1542438abd1f914a to your computer and use it in GitHub Desktop.
AddressBook Dictionary
This file contains hidden or 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
var dict = [ | |
kABPersonAddressCityKey: "Vienna", | |
kABPersonAddressZIPKey: "1110", | |
kABPersonAddressStreetKey: "Rinnböckstrasse 48/17", | |
kABPersonAddressCountryKey: "Austria" | |
] | |
Error on line 1: "Type of expression is ambiguous without more context" | |
Error on line 2: "'_' is not convertible to 'StringLiteralConvertible' |
Why the "as!" ?
It seems CFString
is not Hashable
and cannot be a key. I guess inferring ambiguity is there, because it does bridge to String
.
var dict: [String:String] = [
kABPersonAddressCityKey: "Vienna",
kABPersonAddressZIPKey: "1110",
kABPersonAddressStreetKey: "Rinnböckstrasse 48/17",
kABPersonAddressCountryKey: "Austria"
]
Could you just implement the Hashable Protocol for CFString? Something simple that does the cast and returns the NSString Hash.
Didn't try, but something like:
extension CFString : Equatable, Hashable {
public var hashValue: Int {
return (self as! String).hashValue
}
}
public func ==(lhs: CFString, rhs: CFString) -> Bool {
return (lhs as! String) == (rhs as! String)
}
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ugly but work for me ...
or