ios – Storing reference of UIImage to the property in class declared in Swift package becomes nil immediately

0
60

[ad_1]

I want to store reference of Image from main Application assets in to the one of property of the class which is implemented in then Module of Swift package Manager but reference to property of class instance is nil. Below is class declared Package

    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
    }
}

Here is I’m instantiating class

let image = UIImage(named: item.imageName)?.withRenderingMode(.alwaysTemplate)

image have non nil value

let item = AMGridItem(title: "", text: status, image: image, type: type)

item.image is nil

[ad_2]