I am new to iOS Development.Here I am trying to go for different destination views using foreach loop
struct NewView : View
{
var arrayofviews //here I need array of views
var body:some View
{
List
{
ForEach(array)
{(item) in
NavigationLink(destination: item)
{
Text("Click Here")
}
}
}
}
}
I tried following
var arrayofviews=[view1(),view2(),view3()] as! [Any]
then I am getting this error Cannot convert value of type 'view1' to expected element type 'Array.ArrayLiteralElement' (aka 'AnyView')
here view1,view2,view3 are custom views
struct view1:View
{
var body:Some View
{
Text("...")
...
}
}
//similarly view2 and view3 also
Thanks 'Mohammad Rahchamani' for your suggestion !!!