views:

72

answers:

3

Hi!

I am trying to override NSTextView - (void)complete:(id)sender method but I can't find any example on how to do it. What does this method do? There are examples, or where I can find the original implementation?

Thank you!

—Alberto

+1  A: 

I believe you should try to do your thing in the delegate with below method instead.

- (NSArray *)textView:(NSTextView *)textView 
          completions:(NSArray *)words 
  forPartialWordRange:(NSRange)charRange 
  indexOfSelectedItem:(NSInteger *)index

One rarely need to subclass in Cocoa. When thinking about it check the delegate methods again.

epatel
+3  A: 

It's all there in the documentation of complete:

Discussion

The delegate may replace or modify the list of possible completions by implementing textView:completions:forPartialWordRange:indexOfSelectedItem:. Subclasses may control the list by overriding completionsForPartialWordRange:indexOfSelectedItem:.

Normally, one doesn't need to reimplement complete:.

Georg
+1. That's almost exactly what I was about to post.
outis
+1  A: 

Also checkout the SearchField example, especially the implementation.

Zoran Regvart