What to do with Swift's "try?" that cause "Result of try? is unused"? [duplicate] What to do with Swift's "try?" that cause "Result of try? is unused"? [duplicate] swift swift

What to do with Swift's "try?" that cause "Result of try? is unused"? [duplicate]


As your requirement, "At the same time I don't care about the exception that may be thrown, I just want to call method", do this:

try! managedObjectContext.save()

But it will crash if an error is thrown. So, use below code snip for safe:

_ = try? managedObjectContext.save()


I think you need something like this.

Do { try managedObjectContect.Save()}catch let error {   print("error")}