是否可以在Swift中捕获NSInternalInconsistencyException? [英] Is it possible to catch a NSInternalInconsistencyException in Swift?

查看:166
本文介绍了是否可以在Swift中捕获NSInternalInconsistencyException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Swift中捕获NSInternalInconsistencyException?
如果是,怎么办?

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

推荐答案

例如,可以使用 https://github.com/williamFalcon/SwiftTryCatch 。首先将其添加到您的Podfile中:

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

use_frameworks!
pod 'SwiftTryCatch'

然后在您的代码中 import SwiftTryCatch ,然后您可以捕获这样的Objective-C异常

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
})

这篇关于是否可以在Swift中捕获NSInternalInconsistencyException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆