I have this code part:
let strValue = String()
textfield.stringValue = strValue!
The problem is that strValue
can be nil.
For this I check it like this:
if strValues.isEmpty() {
textfield.stringValue = ""
} else {
textfield.stringValue = strValue!
}
But I there an quicker and easier way to do this?
I read something like ??
to solve it. But I don't know how to use it?
UPDATE thanks a lot for the many feedbacks. now i unterstand the ?? operator, but how i realize it in this situation?
let person = PeoplePicker.selectedRecords as! [ABPerson]
let address = person[0].value(forProperty: kABAddressProperty) as?
ABMultiValue
txtStreet.stringValue = (((address?.value(at: 0) as! NSMutableDictionary).value(forKey: kABAddressStreetKey) as! String))
how can i usee the ?? operator in the last line of my code?
UPDATE 2 Okay i got it!
txtStreet.stringValue = (((adresse?.value(at: 0) as? NSMutableDictionary)?.value(forKey: kABAddressStreetKey) as? String)) ?? ""