'how to use text.index

func updatebuffer () {
        let textDocumentProxy = self.textDocumentProxy
        
        var grabedtext = self.textDocumentProxy.documentContextBeforeInput
        let getIndex = grabedtext.index(before: buffer.endIndex)
        let buffer = grabedtext[getIndex-2..<getIndex]
        self.textDocumentProxy.deleteBackward()
        
        for (there is "a" in newbuffer){
        let buffer2 = buffer.replaceingOccurrences(of: "a", with: "à")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source