我为以下内容创建了一个扩展UIView
:
import UIKit
extension UIView {
var frameHeight : CGFloat {
get {
return self.frame.size.height
}
set(newHeight) {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y,self.frame.size.width, newHeight)
}
}
}
然后我在自己的方法中使用了这个UIView
:
class MyView: UIView {
func updateHeight() {
self.frameHeight = 200.0
setNeedsDisplay()
}
}
我得到一个编译错误:
While emitting IR SIL function @_TFC15Simple15MyView10updateHeightfS0_FT_T_ for 'updateHeight' at /MyView.swift:88:5
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: swift frontend command failed due to signal (use -v to see invocation)
Command /Applications/Xcode6-Beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254
当我注释掉该行时self.frameHeight = 200.0
,编译错误就消失了。
它是一个错误吗?还是我做错了什么?谢谢。