Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to catch a NSInternalInconsistencyException in Swift?

Is it possible to catch a NSInternalInconsistencyException in Swift ? If it is, how could that be done?

like image 219
smat88dd Avatar asked Jul 14 '16 07:07

smat88dd


1 Answers

It can be done for example with https://github.com/williamFalcon/SwiftTryCatch. First add it to your Podfile:

use_frameworks!
pod 'SwiftTryCatch'

Then in your code import SwiftTryCatch and then you can catch Objective-C exceptions like this

SwiftTryCatch.try({ 
    // try block
}, catch: { (error) in
    // catch block
}, finally: {
    // finally block
})
like image 114
Leszek Szary Avatar answered Sep 20 '22 18:09

Leszek Szary