try swift code example
Example 1: swift do catch
do {
let sandwich = try makeMeSandwich(kitchen)
} catch let error {
print(error.localizedDescription)
}
Example 2: try? as? in swiftui
if let result = try? checkPassword("password") {
print("Result was \(result)")
} else {
print("D'oh.")
}