ScanUserListViewController.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // ScanUserListViewController.m
  3. // HMLG Scan Order
  4. //
  5. // Created by Rui Zhang on 2/22/22.
  6. // Copyright © 2022 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "ScanUserListViewController.h"
  9. #import "RAUtils.h"
  10. @interface ScanUserListViewController ()
  11. @end
  12. @implementation ScanUserListViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.title = @"Select User";
  16. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  17. NSString *documents = [paths objectAtIndex:0];
  18. NSString* unZipTo=[documents stringByAppendingPathComponent:@"download"];
  19. NSString* file = [unZipTo stringByAppendingPathComponent:@"offlineOrderUsers.json"];
  20. self.user_list = [RAUtils dictfromfile:file];
  21. // Do any additional setup after loading the view.
  22. }
  23. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  24. return self.user_list.count;
  25. }
  26. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  27. static NSString *CellIdentifier = @"Cell";
  28. // UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  29. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  30. if (!cell) {
  31. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  32. }
  33. cell.textLabel.text = self.user_list[indexPath.item];
  34. return cell;
  35. }
  36. - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  37. if(self.returnValue)
  38. self.returnValue(self.user_list[indexPath.item]);
  39. [self dismissViewControllerAnimated:TRUE completion:nil];
  40. }
  41. /*
  42. #pragma mark - Navigation
  43. // In a storyboard-based application, you will often want to do a little preparation before navigation
  44. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  45. // Get the new view controller using [segue destinationViewController].
  46. // Pass the selected object to the new view controller.
  47. }
  48. */
  49. @end