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 9174727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:48:02+00:00 2026-06-17T16:48:02+00:00

I want to auto complete a text field from a custom value Having researched

  • 0

I want to auto complete a text field from a custom value

Having researched Google and SO here UITextField Autocomplete – iPhone SDK

I tried this:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

    if ([string isEqualToString:@"Fac"]) {
        _clientField.text = @"Factory";
    }

    return YES;
}

Problem is I get no predicted value entered Factory, just the typed value Fac

EDIT

Tried this based on answers…

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

if ([string isEqualToString:@"Fac"]) {
    _clientField.text = [_clientField.text stringByReplacingCharactersInRange:range
                                                   withString:@"Factory"];
  }

  return NO;
}

Still the same

  • 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-17T16:48:02+00:00Added an answer on June 17, 2026 at 4:48 pm

    I checked your sample code and the text field’s delegate is not set.

    You can set it in your view controller using

    _clientField.delegate = self;
    

    Additionally you need to use a slightly different method to get the text which the users sees. Something like this:

    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
        NSString *currentString = [textField.text stringByReplacingCharactersInRange:range withString:string];
        if ([currentString isEqualToString:@"Fac"]) {
            textField.text = @"Factory";
            return NO;
        }
        return YES;
    }
    

    Note that you probably want to fine tune this a bit, since it e.g. also autocompletes when the user deletes text. But this should get you on the right track.

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

Sidebar

Related Questions

Simple text field change after jquery auto complete select event. I want to split
i want to make autocomplete for many text input field... but with this autocomplete
I've been trying to add auto complete functionality to a text box. I want
I want to store the value returned from a webservice to a hidden field
I have Auto completed text view,i want to filter the items present in the
Is there a web (i.e. html) text editor with autocomplete? Let's say I want
And what if you want to autocomplete passwords? I am using similar thing here...
I have a long text field and what I want to do is that
I tried to make an auto-complete TextBox like Google Search with C# in a
I'm having a pretty nasty problem with an auto-completing textbox. I want to initiate

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.