gpt4 book ai didi

swift 2.0 错误 : warning: could not load any Objective-C class information

转载 作者:搜寻专家 更新时间:2023-11-01 05:38:44 25 4
gpt4 key购买 nike

我收到这个错误:

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。

更新

如果你不这样初始化它们而是像这样写它们,即

var trackLayer: CERangeSliderKnobLayer!

然后你得到一个错误:

fatal error: unexpectedly found nil while unwrapping an Optional value

类似的东西:

trackLayer.backgroundColor = UIColor.blueColor().CGColor

最佳答案

出于某种原因,答案是更改我的类,以便不初始化 weak 属性:

import QuartzCore


class CERangeSliderKnobLayer: CALayer {

var highlighted = false
weak var slider: CERangeSlider!

}

关于 swift 2.0 错误 : warning: could not load any Objective-C class information,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33572385/

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