I am attempting to construct a high-performance textual content editor just like the one discovered within the Apple Notes app.
To remove uncertainties, I’ve created a SwiftUI app from scratch and added solely the TextEditor view, nothing else.
struct ContentView: View {
@State non-public var textual content = ""
var physique: some View {
TextEditor(textual content: $textual content)
.body(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
}
}
I’ve inserted a string with 347,023 characters, and textual content modifying may be very sluggish, gradual, and textual content choice is even slower.
The identical string within the Apple Notes app displays clean textual content modifying and choice.
I’ve additionally tried utilizing UIKit with UITextView, however I am experiencing the identical efficiency drop.
How can I obtain the identical stage of clean textual content modifying and efficiency because the Apple Notes app?
I seen that the next instance may be very clean however you may’t edit the textual content:
https://developer.apple.com/documentation/uikit/textkit/using_textkit_2_to_interact_with_text
Might you present a primary instance to start out with for making a extremely performant textual content editor on iOS?