self.presentTextInputControllerWithSuggestions(nil, allowedInputMode: WKTextInputMode.Plain) { (results:[AnyObject]!) -> Void in
// results can be nil
if let speech = results.first as? String {
debugPrint(speech)
}
}
Excuse my ignorance, I'm afraid I've missed some basic understanding of optionals. I'm under the impression that !
, the implictly unwrapped optional indicator, is a guarantee that the variable of that type is not nil. Yet this very straightforward Apple API will infrequently return me nil
.
Is this an unintended bug or part of the spec for Optionals? Because if this is part of the spec, I don't understand why there are optionals in the first place as opposed to having variables that can either be present or nil
.