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

  • SEARCH
  • Home
  • 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 8953399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:05:07+00:00 2026-06-15T14:05:07+00:00

Does anyone know of any class or lib that can implement autocompletion to an

  • 0

Does anyone know of any class or lib that can implement autocompletion to an NSTextField?

I’am trying to get the standard autocmpletion to work but it is made as a synchronous api. I get my autocompletion words via an api call over the internet.

What have i done so far is:

- (void)controlTextDidChange:(NSNotification *)obj
{
    if([obj object] == self.searchField)
    {
        [self.spinner startAnimation:nil];
        [self.wordcompletionStore completeString:self.searchField.stringValue];

        if(self.doingAutocomplete)
            return;
        else
        {
            self.doingAutocomplete = YES;
            [[[obj userInfo] objectForKey:@"NSFieldEditor"] complete:nil];
        }
    }
}

When my store is done, i have a delegate that gets called:

- (void) completionStore:(WordcompletionStore *)store didFinishWithWords:(NSArray *)arrayOfWords
{
    [self.spinner stopAnimation:nil];
    self.completions = arrayOfWords;
    self.doingAutocomplete = NO;
}

The code that returns the completion list to the nstextfield is:

- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index
{
    *index = -1;
    return self.completions;
}

My problem is that this will always be 1 request behind and the completion list only shows on every 2nd char the user inputs.

I have tried searching google and SO like a mad man but i cant seem to find any solutions..

Any help is much appreciated.

  • 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-15T14:05:08+00:00Added an answer on June 15, 2026 at 2:05 pm

    Instead of having the boolean property doingAutocomplete, make the property your control that made the request. Let’s call it autoCompleteRequestor:

    @property (strong) NSControl* autoCompleteRequestor;
    

    So where you set your current property doingAutocomplete to YES, instead store a reference to your control.

    - (void)controlTextDidChange:(NSNotification *)obj
    {
        if([obj object] == self.searchField)
        {
            [self.spinner startAnimation:nil];
            [self.wordcompletionStore completeString:self.searchField.stringValue];
    
            if(self.autoCompleteRequestor)
                return;
            else
            {
                self.autoCompleteRequestor = [[obj userInfo] objectForKey:@"NSFieldEditor"];
            }
        }
    }
    

    Now when your web request is done, you can call complete: on your stored object.

    - (void) completionStore:(WordcompletionStore *)store didFinishWithWords:(NSArray *)arrayOfWords
    {
        [self.spinner stopAnimation:nil];
        self.completions = arrayOfWords;
        if (self.autoCompleteRequestor)
        {
           [self.autoCompleteRequestor complete:nil];
           self.autoCompleteRequestor = nil;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of any websites, or (preferably) downloadable packages that you can use
Does anyone know of any examples or code that shows a class or struct
Does anyone know about any other than com.idataconnect.lib.ascii85codec java projects that do something like
Does anyone know any good resources with tasks or problems to get practice in
Does anyone know any site or book that presents problems like python challenge ,
does anyone know any sort of app that lets users visit a page on
Does anyone know any trick I could use to keep the Derived class until
Does anyone know any as3 libraries that allow you to scale, rotate, skew, etc..
Does anyone know of any resources or books I can read to help me
Does anyone know of any tools out there which can summarize changes to Java

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.