Search code examples
iphonensurlconnectionuisearchdisplaycontroller

NSUrlConnection with table view and search display controller


I am writing an iPhone app which gets data from a mysql database. I am trying to use a search display controller to search the database as the user types input into the search bar, but the problem I am having is that uitableview methods are called before the nsurlconnection methods.

My current coding logic is as follows;

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope 
//code to start connection

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
//populate array of search results

//Load data into search results
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

Does anyone know how to make this work or know of another method of doing this? If something is unclear or you need some more information please let me know.

Thank you for your help.


Solution

  • Are you calling [tableView reloadData] after populating search results?