Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9234323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:45:48+00:00 2026-06-18T06:45:48+00:00

I want to check if a user backspaces a character in a textView if

  • 0

I want to check if a user backspaces a character in a textView if there are any of that same character connecting it for it to delete them all…

For example if the character I’m checking for is “e” I have the text “easy heeeeeello” and the user starts hitting backspace it will become:

easy heeeeeello -> easy heeeeeell -> easy heeeeeel -> easy heeeeee -> easy h

The code should detect that a backspace was pressed.
Then it will detect which text is going to be deleted, and if that text is a character (in our case “e”) it will check if there are more “e”s touching that “e” creating a strand of “e”s and delete them all.

Can you help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:45:49+00:00Added an answer on June 18, 2026 at 6:45 am

    OK, so I wrote this code, and it works for me

    -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
        if([text isEqualToString:@""]) {
        //Detected backspace character as the new character is @"" meaning something will be deleted
    
            char toDelete = [textView.text characterAtIndex:range.location];
    
            int duplicateCharCount = 0;
            for(int i =range.location-1; i>=0; i--) {
    
                if([textView.text characterAtIndex:i] == toDelete) {
                    duplicateCharCount++;
                } else {
                    break;
                }  
            }
    
            NSRange newRange = NSMakeRange(0, range.location - duplicateCharCount);
            [textView setText:[textView.text substringWithRange:newRange]];
    
            return NO;
        } else {
            return YES;
        }
    }
    

    I know its not the best implementation, but now you know how to proceed

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to do a check if a user id exists in all of
More precisely: i want to check if the user enters his same password as
I want to check user input in the textbox. If the first character is
I have a textbox with string, and want to check that user dropped text
I have a problem that I want to check the user who starts the
i want to check that user upload file is image or not. how i
I want to check/filter user input. If, for example, the user chosen value does
I want to check for user inactivity in my application. I did a little
I want to check if user input a positive integer number. 1 = true
So I want to check if the user is in specific county $ip =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.