I want to call some method which can throw
something. At the same time I don't care about the exception that may be thrown, I just want to call method. However, if I try to do something like this:
try? managedObjectContext.save()
I get warning "Result of try? is unused". What should I do in this case? Silence warning? How?
Do something like this:
let error: NSError = try? managedObjectContext.save()
? Expression becomes twice as large and I get unused constant.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With