如何获取在 SwiftUI TextEditor 中输入的字符串并将其存储在数组中?

How can I get the string entered in the SwiftUI TextEditor and store it in an array?

我想获取在SwiftUI 的TextEditor 中输入的字符串,并将其存储在一个数组中。 我应该如何附加到文本数据?

struct TextEditorTest: View {

    @State var textdata: [String] = []

    @State var text1: String = ""
    
    var body: some View {
        TextEditor (text: $text1)
        
    }

}

@State var textdata: [String] = []
@State var text1: String = ""

var body: some View {
    TextEditor (text: $text1)
        .onChange(of: text1) { newValue in
            print(newValue)
            //perform your logic here because it will trigger as soon as value is changed in field
        }
}