Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. //
  2. // ViewController.m
  3. // Lab4
  4. //
  5. // Created by Анна Родионова on 12/12/2018.
  6. // Copyright © 2018 Veirisa. All rights reserved.
  7. //
  8.  
  9. #import "ListModel.h"
  10. #import "ModelManager.h"
  11. #import "ViewController.h"
  12.  
  13. @interface ViewController ()
  14.  
  15. @property (weak, nonatomic) IBOutlet UITableView *listTableView;
  16. @property (strong, nonatomic) NSArray* model;
  17.  
  18.  
  19. @end
  20.  
  21. @implementation ViewController
  22.  
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25.  
  26. self.model = [ModelManager getModel];
  27.  
  28. //[self.listTableView setSectionIndexBackgroundColor: [UIColor blueColor]];
  29.  
  30. //[self.listTableView reloadData];
  31.  
  32. }
  33.  
  34. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  35. return [self.model count];
  36. }
  37.  
  38. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  39. return [(NSArray*)self.model[section] count] + 1;
  40. }
  41.  
  42. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  43.  
  44. return ((ListModel*)self.model[section]).name;
  45. }
  46.  
  47. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  48.  
  49. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ListCell"];
  50. ListModel* listModel = (ListModel*)self.model[indexPath.section];
  51. if (indexPath.row == [listModel.tasksList count]) {
  52. [cell.backgroundView setBackgroundColor:[UIColor blueColor]];
  53. } else {
  54. [cell.textLabel setText: listModel.tasksList[indexPath.row]];
  55. }
  56.  
  57. return cell;
  58. }
  59.  
  60.  
  61. //return [NSString stringWithFormat:@"%@%ld", @"dog", section];
  62.  
  63. //return [tableView dequeueReusableCellWithIdentifier:@"ListCell"];
  64.  
  65. /*
  66. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  67.  
  68. //return [tableView dequeueReusableCellWithIdentifier:@"ListCell"];
  69.  
  70. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ListCell"];
  71. [cell.textLabel setText: [NSString stringWithFormat:@"%@%ld", @"cat", indexPath.row]];
  72. //[cell.textLabel setFont:[UIFont systemFontOfSize:10]];
  73.  
  74. return cell;
  75.  
  76.  
  77. GPFinancePaymentsCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([GPFinancePaymentsCell class]) forIndexPath:indexPath];
  78.  
  79. if (cell == nil) {
  80. cell = [[GPFinancePaymentsCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:NSStringFromClass([GPFinancePaymentsCell class])];
  81. }
  82.  
  83. [cell initWithInformation:self.agreements[indexPath.row - 1]];
  84.  
  85. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  86.  
  87. return cell;
  88. }
  89. */
  90.  
  91. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement