tags:

views:

429

answers:

4

I'm wondering if there is an existing class or library code in Cocoa Touch that shows the user a list of real-time suggestions while they are entering text input, with the suggestions based on similarities between what they have already entered and previous entries.

For instance, see how Safari on the iPod Touch shows realtime suggestions when you start to type in a URL, based on previously visited sites.

If there is a standard way of doing this, I'd love to know! If not, suggestions for a reasonable way to implement this -- subclass UITextField and go from there? -- would be welcome.

+1  A: 

You need to check out the UITextFieldTextDidChangeNotification to see when the UITextField is changed. Look at NSNotificationCenter to see how to register an observer.

danimal
+1  A: 

I'd suggest looking at the delegate method:

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

You'll have to roll your own auto completion view similar to what Apple uses for its suggestive auto complete feature.

pat
A: 

Thanks danimal and pat. Those both make sense. Anyone else have suggestions before I build this from scratch?

A: 

As this message starts to be a little old, is there any existing framework now that allow to achieve this ?

Dirty Henry