2
我得到這個錯誤:雨燕2.0的錯誤:警告:無法加載任何Objective-C類信息
warning: could not load any Objective-C class information
也
Thread 1: EXC_BAD_ACCESS(code=2,address=0x7fff5588dfb8)
...分配該類時:
import UIKit
import QuartzCore
class CERangeSliderKnobLayer: CALayer {
var highlighted = false
weak var slider = CERangeSlider()
}
對於像這樣的變量:
import UIKit
class CERangeSlider: UIControl {
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
// Drawing code
}
*/
var maximumValue = CGFloat()
var minimumValue = CGFloat()
var upperValue = CGFloat()
var lowerValue = CGFloat()
var trackLayer = CERangeSliderKnobLayer()
var upperKnobLayer = CERangeSliderKnobLayer()
var lowerKnobLayer = CERangeSliderKnobLayer()
...
}
這沒有意義。我知道我的項目中絕對沒有Objective C。這都是Swift。
UPDATE
如果你不初始化他們這樣的,而不是把它們寫像這樣,即
var trackLayer: CERangeSliderKnobLayer!
然後你會得到一個錯誤:
fatal error: unexpectedly found nil while unwrapping an Optional value
的東西如:
trackLayer.backgroundColor = UIColor.blueColor().CGColor