i need a little extra help with the onMove modifier and a multi array. Is there a way to use the onMove modifier with a multiarray? Thanks in advance!
@State var multiArray = [["String_1"],["String_2"]]
@State var edit: Bool = false
var body: some View {
NavigationView{
List {
Section{
Button {
edit.toggle()
} label: {
Text("Edit")
}.buttonStyle(BorderlessButtonStyle())
}
ForEach(0..<multiArray.count, id:\.self ){ i in
ForEach(multiArray[i], id:\.self ){ string in
Text(string)
}
}.onMove(perform: move2)
}.environment(\.editMode, .constant(edit ? EditMode.active : EditMode.inactive))
}
}
func move2(from source: IndexSet, to destination: Int) {
multiArray.move(fromOffsets: source, toOffset: destination)
}