I am currently using the following (clumsy) pieces of code for determining if a (non-empty) Swift dictionary contains a given key and for obtaining one (any) value from the
Why not simply check for dict.keys.contains(key)?
Checking for dict[key] != nil will not work in cases where the value is nil.
As with a dictionary [String: String?] for example.