How can I insert the following code into the database to add to an array in SwiftData and delete at the specified point?
struct DataModel: Identifiable, Codable {
var data: [[String]]
}
struct ContentView: View {
@State var dataArray: [DataModel] = []
var body: some View {
VStack {
Button("Add Data") {
dataArray[0].data.append(["Add Data"])
}
Button("Add Data1") {
dataArray[0].data[0].append(["Add Data1"])
}
Button("Remove Data") {
dataArray[0].data[0].remove(at: 0)
}