I have a view called TagView which creates a list of tags using LazyHGrid I am trying to get the array of tags that loads from the web service and pass it from the main view to TagView. Here is the code:
struct TagsView: View {
var tags: Array<String>
private var layout = [GridItem(.fixed(30))]
var body: some View {
HStack {
Spacer()
GeometryReader { geo in
ScrollView(.horizontal, showsIndicators: false) {
LazyHGrid(rows: layout) {
ForEach(tags, id: \.self) {
Button("\($0)") {
}
.font(.callout.bold())
}
}
}
}
After creating the variable: var tags: Array<String> I need to get the array from the main view like this:
struct MainView: View {
var model: Model
var body: some View {
VStack {
TagsView(tags: model.tags)
}
}
}
But I am getting this error:
TagsView' initializer is inaccessible due to 'private' protection level
I tried with @Binding and still no luck, any help would be great!

modelinto yourMainView.@State private var array = [String]() init() { array = model.tags }