10

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.

Boon
  • 40,656
  • 60
  • 209
  • 315
  • 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
  • 2
    I 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
  • 1
    On 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

0 Answers0