So I have a Type that I would like to make dynamic at the call site:
struct DynamicView<Content: View>: View {
let content: Content
var body: some View {
content
}
}
using some type of function that would convert it into something concrete
static func contentCreator<T: View>(id: Int) -> T {
switch id {
case 0:
return FirstView() //<-- Xcode is demanding that I state as! T here
}
}
where FirstView
struct FirstView: View {
var body: some View {
Circle()
}
}
Am I approaching this wrong or what? As long as they all conform to a common protocol, they should be interchangeable right?