Closed ghost closed 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;
Can you check to see if the NSError is not nil after the NSJSONSerialization and NSLog it out?
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.
Fixed it. It was a problem in my code.
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="
(void)autoCompleteTextField:(MLPAutoCompleteTextField )textField possibleCompletionsForString:(NSString )string completionHandler:(void (^)(NSArray *))handler { dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); dispatch_async(queue, ^{ if(self.simulateLatency){ CGFloat seconds = arc4random_uniform(4)+arc4random_uniform(4); //normal distribution NSLog(@"sleeping fetch of completions for %f", seconds); sleep(seconds); }
handler(suggestionlist); }); }
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?