Fire Fist
Fire Fist

Reputation: 7060

How to delete a letter before last letter in textDocumentProxy in iOS?

We can use deleteBackward in TextDocumentProxy to delete a last letter.

Now i need to delete a letter of last letter.

Eg. Apple , i want to delete l letter before e.

How can i do it?

Upvotes: 0

Views: 565

Answers (2)

Leo Moon85
Leo Moon85

Reputation: 150

Here what I did... Its not perfect but good for a now to delete last word. You might found it useful.

-(void) removeLastWordFromInput{
    for (int i = self.textDocumentProxy.documentContextBeforeInput.length - 1;i > 0; i--) {
        if ([self.textDocumentProxy.documentContextBeforeInput characterAtIndex:i] == ' ')
            return;

        //delete last character
        [self.textDocumentProxy deleteBackward];
    }
}

Upvotes: 0

Léo Natan
Léo Natan

Reputation: 57060

Get the last character from the documentContextBeforeInput, delete twice, and add the character as text.

If you feel this API is lacking, make sure to open a bug report and/or an enhancement report with Apple.

Upvotes: 1

Related Questions