Backspace in UITextView substringToIndex , app is crashing .
- by user271753
Hey Guys check this code ( My Custom Keyboard) :
-(IBAction) updateTextBackSpace:(id)sender
{
if([txtview.text length]>0)
{
NSString *deletedLastCharString = [txtview.text substringToIndex:([txtview.text length]-1)];
[txtview setText:deletedLastCharString];
}
else
{
NSLog("End");
}
I am able to erase the letters ( backspace ) but after the first letter is erased and if I press backspace one more time then the application crashes ..
AND the main thing is that I can't figure out how to change this code so that ,
I can erase any text in any give line at the cursor, the backspace starts to erase from end of the line .
Please Help