0

In Swift, how do I guard against calling storyboard.instantiateViewControllerWithIdentifier on an identifier that's not valid?

Most solutions I have seen on SO uses try...catch in Objective-C, but the solution does not work in Swift because instantiateViewControllerWithIdentifier does not throw.

bartektartanus
  • 15,284
  • 6
  • 74
  • 102
Boon
  • 40,656
  • 60
  • 209
  • 315

1 Answers1

0

I believe it's a bug in the current API (iOS 9 as of today) for the Swift version. Either storyboard.instantiateViewControllerWithIdentifier should return UIViewController? or it should be able to throw exception. The Objective-C version throws exception which can be dealt with try-catch clause.

megakilo
  • 128
  • 7