EddyBorja / MLPAutoCompleteTextField

UITextfield subclass with autocomplete menu. For iOS.
Other
1.21k stars 222 forks source link

Auto Suggestion based on user input #31

Closed ghost closed 10 years ago

ghost commented 10 years ago

Is it possible to auto suggest item based on user input. fx. I have the following url "https://itunes.apple.com/search?term=" where users have to enter a search term?

I have tried to the following:

define baseURL @"https://itunes.apple.com/search?term="

But I got the following error:

GAIUncaughtExceptionHandler(NSException ) (GAIUncaughtExceptionHandler.m:41): Uncaught exception: data parameter is nil 2014-05-15 11:49:54.224 MLPAutoCompleteDemo[6349:5503] GoogleAnalytics 2.0b4 void GAIUncaughtExceptionHandler(NSException ) (GAIUncaughtExceptionHandler.m:38): Bailing on multiple uncaught exceptions: data parameter is nil 2014-05-15 11:49:54.224 MLPAutoCompleteDemo[6349:5503] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'

Any suggestions why it is not working?

damien-rivet commented 10 years ago

Hi there,

Not the solution for the current issue, just a little cleanup :

From :

if(self.testWithAutoCompleteObjectsInsteadOfStrings && suggestionlist != nil){
    completions = suggestionlist;
} else {
    completions = suggestionlist;
}

To :

completions = suggestionlist;
EddyBorja commented 10 years ago

Can you check to see if the NSError is not nil after the NSJSONSerialization and NSLog it out?

ghost commented 10 years ago

The data are retrieved from the web service without problem but the error occurs at this line: NSString* artistName = [[jsonObject objectAtIndex:i] objectForKey:@"artistId"]; Which doesnt make any sense because I have tested the code outside MLPAutoCompleteTextField and it was working fine.

ghost commented 10 years ago

Fixed it. It was a problem in my code.