"Value of optional type 'String??' not unwrapped; did you mean to use '!' or '?'?" -
I got this weird compiler error today, which was entirely confusing due to the two question marks after String
.
I have a dictionary s
, of type [String : String?]
, and a function which accepts all arguments as String?
s. Specifically (from 5813's method of copying user-selected information into a dictionary), I have an elaborated version of the following:
func combine(firstname: String?, lastname: String?) {...}
var text = combine(s["kABPersonFirstNameProperty"], lastname: s["kABPersonLastNameProperty"])
I'm getting the error on the second line, and I'm wondering why it's so. If the values in s
are of type String?
, shouldn't that be accepted by combine()
, since it's arguments are supposed to be of the same type? Why, then, would I get this error and how can I fix it?