2

Are there any good ways to catch exceptions originating from function calls by third-party (closed source) libraries/frameworks when the function does not explicitly throw?

Curious how to properly handle this in both Obj-C and Swift.

Ex: Integrate closed source Analytics SDK into my app. That SDK is crashing during initialization. I don't want my app to crash, but I want the app to continue functioning without the Analytics SDK.

iOS dev
  • 522
  • 6
  • 14
  • 2
    In Swift *no throw, no catch* – vadian Oct 17 '17 at 17:38
  • @vadian - I figured in Swift, a non-`throw`ing function could not be wrapped in a `catch`. However, I was wondering if the same is true in Obj-C. For example, what if I wrote a Obj-C class which caught the exception and called that from my Swift project? Does such a mechanism exist? – iOS dev Oct 18 '17 at 04:01
  • Unlike Swift in ObjC you can catch exceptions so I guess you can catch also exceptions caused by the Swift code but it's always a better idea to write reliable code to avoid any exception. – vadian Oct 18 '17 at 04:08
  • @vadian late to the party, but your comment should be an (accepted?) answer – superjos Mar 13 '19 at 13:39

0 Answers0