How to catch runtime exception in Swift? I have found no mention of this. The current Swift try..catch only works for method that throws exception.
Asked
Active
Viewed 1,960 times
10
-
You don't "catch" exceptions in Swift. Nice explanations here: http://stackoverflow.com/a/24030038/2227743 – Eric Aya Mar 15 '16 at 11:37
-
I am trying to catch error caused by passing in an invalid identifier to storyboard.instatiateViewController. Can't find a way in Swift. – Boon Mar 15 '16 at 11:39
-
2I am asking a general question of whether Swift can catch runtime exception like Objective-C can. The case I provide is an example, I am sure there are other cases. Runtime exception by nature is something you did not predict. – Boon Mar 15 '16 at 12:27
-
1On the latest version of Xcode, You can add a swift exception, on the break points tab, press the + button and choose swift exception – user1046037 Mar 16 '16 at 04:03