[ad_1]
I’m making an attempt to initialize the WidgetKit struct WidgetInfo for unit testing a operate that takes WidgetInfo as an argument:
let widgetInfo = WidgetInfo()
This offers me the error:
‘WidgetInfo’ can’t be constructed as a result of it has no accessible initializers
I attempted including:
extension WidgetInfo {
public init() {}
}
and I can initialize – yay! However then I attempt to set one in all its properties
widgetInfo.household = .systemSmall
and get the error: Can not assign to property: ‘household’ is a ‘let’ fixed
I attempted one other initializer with arguments:
extension WidgetInfo {
public init(household: WidgetFamily, form: String) {
self.household = household
self.form = form
}
}
and I get the error: ‘let’ property ‘household’ might not be initialized straight; use “self.init(…)” or “self = …” as a substitute
I am caught – is there a manner for me to initialize WidgetInfo? Or one other option to check a operate that takes WidgetInfo as an argument?
[ad_2]
