gpt4 book ai didi

swift - 命令因信号 : Segmentation fault: 11 while emitting IR SIL function 而失败

转载 作者:搜寻专家 更新时间:2023-10-30 21:49:52 25 4
gpt4 key购买 nike

我想在 UITextView 的扩展中添加闭包属性,所以我使用 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
}

}

但它告诉我一个错误:

Command failed due to signal: Segmentation fault: 11.

这是错误的图片

my code

谁能告诉我为什么并给我一个深刻有意义的解释,非常感谢!

最佳答案

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

var isSomething: Bool!

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

只需添加 !在您的属性(property)上

var isSomething: Bool!

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

关于swift - 命令因信号 : Segmentation fault: 11 while emitting IR SIL function 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40968517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com