由于信号,命令失败:分段错误:发出IR SIL功能时为11 [英] Command failed due to signal: Segmentation fault: 11 while emitting IR SIL function

查看:138
本文介绍了由于信号,命令失败:分段错误:发出IR SIL功能时为11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 UITextView 的扩展名中添加闭包属性,因此我使用typealias定义闭包:

I want to add closure properties in the extension of UITextView so I define a closure using typealias:

typealias TextViewHeightDidChangedClosure = (_ currentTextViewHeight:CGFloat)->Void

extension UITextView{

  func setTextViewHeightDidChanged(textViewHeightDidChanged:TextViewHeightDidChangedBlock){
    objc_setAssociatedObject(self, &TextViewHeightDidChangedBlockKey, textViewHeightDidChanged, objc_AssociationPolicy.OBJC_ASSOCIATION_COPY_NONATOMIC)
  }

  func textViewHeightDidChanged()->TextViewHeightDidChangedBlock?{
   let textChanged : ((CGFloat)->Void) = objc_getAssociatedObject(self, &TextViewHeightDidChangedBlockKey) as! TextViewHeightDidChangedBlock
    return textChanged
  }

}

但是它告诉我一个错误,提示:

But it tells me an error that says:


命令由于信号失败:分段错误:11。

Command failed due to signal: Segmentation fault: 11.

这是错误的图片

谁能告诉我原因并给我深刻的解释,非常感谢!

Can anyone tell me why and give me an deep meaningful explanation, thank you very much!

推荐答案

如果在类中声明 Bool!属性,并尝试使用此属性创建三元条件,也会出现此错误:

You can also have this error if you declare a Bool! property in a class and you try to make a ternary condition with this property:

var isSomething: Bool!

func myFunc() {
    let value = isSomething ? "something" : "not"
}

只需添加!在您的财产上

Just add the ! on your property

var isSomething: Bool!

func myFunc() {
    let value = isSomething! ? "something" : "not"
}

这篇关于由于信号,命令失败:分段错误:发出IR SIL功能时为11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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