I'd like to create an UISearchBar function, which gets called like the search in the App Store: Execute the function (NSURLConnection) after a few seconds (NSTimer) the user did finish typing and just one time for this period.
Does anyone have an idea?
EDIT
self.currentTaskID = self.currentTaskID + 1;
NSInteger taskID = self.currentTaskID;
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), queue, ^{
if (taskID == self.currentTaskID)
{
NSMutableURLRequest *request_CH3 = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://website.com/search.php?term=%@", replaceWhiteSpace]]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:30.0];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
authConnection_CH3 = [[NSURLConnection alloc] initWithRequest:request_CH3 delegate:self];
}
});