You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many Cocoa APIs still throw Objective-C exceptions at runtime. These are impossible to catch in Swift. There are ways to do it by creating an exception catch handler in Objective-C and then use it in Swift, but I prefer to not have any Objective-C code in my projects.
The API could be something like this:
do{tryObjC.catchException{
// Call something here that might throw an NSException.
}}catch{print("An error occurred: \(error)")}
Description
Many Cocoa APIs still throw Objective-C exceptions at runtime. These are impossible to catch in Swift. There are ways to do it by creating an exception catch handler in Objective-C and then use it in Swift, but I prefer to not have any Objective-C code in my projects.
The API could be something like this:
As you can see from the votes on this Stack Overflow question, it's a common need: https://stackoverflow.com/questions/32758811/catching-nsexception-in-swift
The text was updated successfully, but these errors were encountered: