提问人:Dattatray Deokar 提问时间:1/20/2023 更新时间:1/20/2023 访问量:73
将 UIImage 对 Swift 包中声明的类中的属性的引用存储立即变为 nil
Storing reference of UIImage to the property in class declared in Swift package becomes nil immediately
问:
我想将主应用程序资产中的图像引用存储到类的属性之一中,该属性在 Swift 包管理器的模块中实现,但对类实例属性的引用为零。下面是类声明的包
public class AMGridItem {
public var id:Int = 0
public var title:String
public var type:String
public var text:String = ""
public var image:UIImage?
public init(title:String, type:String){
self.title = title
self.type = type
}
public init(title:String, text:String, image:UIImage? = nil, type:String){
self.title = title
self.text = text
self.image = image
self.type = type
}
}
这是我正在实例化类
let image = UIImage(named: item.imageName)?.withRenderingMode(.alwaysTemplate)
图像具有非 NIL 值
let item = AMGridItem(title: "", text: status, image: image, type: type)
item.image 为 nil
答: 暂无答案
下一个:错误:固定冲突:本机模块不能为空
评论
item.imageName