DEV Community

Liang Wang
Liang Wang

Posted on

do try catch

use do { try ... } catch { ... }
or ignore the error just by using try?

do {
    try modelContext.save()
    print("Item updated.")
} catch {
    print("Failed to edit item: \(error.localizedDescription)")
}
Enter fullscreen mode Exit fullscreen mode

or just use try? modelContext.save()

Top comments (0)