Guest User

Untitled

a guest
Feb 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  2. {
  3. return 1;
  4. }
  5.  
  6. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  7. {
  8. return [airportList count];
  9. }
  10.  
  11. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  12. {
  13.  
  14.  
  15.  
  16. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ci"];
  17.  
  18. Details *newDetails = [airportList objectAtIndex:indexPath.row];
  19.  
  20. cell.textLabel.text = newDetails.airport;
  21.  
  22. return cell;
  23.  
  24. }
  25.  
  26. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  27. {
  28.  
  29. Details *newDetails = [airportList objectAtIndex:indexPath.row];
  30. NSString *selectedText = newDetails.airport;
  31. [[NSUserDefaults standardUserDefaults] setObject:selectedText forKey:@"st"];
  32. [[NSUserDefaults standardUserDefaults] synchronize];
  33.  
  34. [self dismissViewControllerAnimated:YES completion:nil];
  35. }
  36.  
  37. @property (strong, nonatomic) UISearchController *searchController;
  38.  
  39. self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
  40. self.searchController.searchResultsUpdater = self;
  41. self.searchController.dimsBackgroundDuringPresentation = NO;
  42. self.searchController.searchBar.delegate = self;
  43.  
  44. self.tableView.tableHeaderView = self.searchController.searchBar;
  45.  
  46. self.definesPresentationContext = YES;
  47.  
  48. - (void)updateSearchResultsForSearchController:(UISearchController *)searchController
  49. {
  50. NSString *searchString = searchController.searchBar.text;
  51. [self searchForText:searchString scope:searchController.searchBar.selectedScopeButtonIndex];
  52. [self.tableView reloadData];
  53. }
Add Comment
Please, Sign In to add comment