Here's my struct that contains a generic:
struct SupportOptions<S> where S: ListStyle {
var text: String = ""
var listStyle: S
}
/**
Allow initializing without a `listStyle` https://stackoverflow.com/a/64530006/14351818
*/
extension SupportOptions where S == InsetGroupedListStyle {
init(text: String = "") {
self.text = text
self.listStyle = InsetGroupedListStyle()
}
}
I then create an instance of it like this:
class ViewController: UIViewController {
var options = SupportOptions()
}
But, when I try changing options.listStyle
, it doesn't work.
options.listStyle = InsetListStyle()
Cannot assign value of type 'InsetListStyle' to type 'InsetGroupedListStyle'