Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  2. {
  3. return departments.count;
  4. }
  5.  
  6. #import "TableViewController.h"
  7. #import "MasterViewController.h"
  8.  
  9. @interface TableViewController ()
  10.  
  11. @end
  12.  
  13. @implementation TableViewController
  14.  
  15. @synthesize selectionH;
  16. @synthesize departments;
  17.  
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. // Do any additional setup after loading the view, typically from a nib.
  21.  
  22. if (selectionH==0){
  23. departments = [NSMutableArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", nil];
  24. }
  25.  
  26. else if (selectionH == 1){
  27. departments = [NSMutableArray arrayWithObjects:@"A", @"B", @"C", @"D", @"E", nil];
  28. }
  29. else{
  30. departments = [NSMutableArray arrayWithObjects:@"Red", @"Green", @"Yellow", @"Blue", nil];
  31. }
  32.  
  33.  
  34. }
  35.  
  36.  
  37.  
  38. - (void)insertNewObject:(id)sender {
  39. [departments insertObject:[NSDate date] atIndex:0];
  40. NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
  41. [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
  42. }
  43.  
  44.  
  45.  
  46.  
  47. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  48. return 1;
  49. }
  50.  
  51.  
  52.  
  53. //vCausing Issue
  54. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  55. return departments.count;
  56. }
  57.  
  58.  
  59.  
  60. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  61. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
  62.  
  63. NSDate *object = departments[indexPath.row];
  64. cell.textLabel.text = [object description];
  65. return cell;
  66. }
  67.  
  68.  
  69.  
  70.  
  71.  
  72. @end
  73.  
  74. #import <UIKit/UIKit.h>
  75.  
  76. @interface TableViewController : UITableViewController
  77.  
  78. @property (strong, nonatomic) id detailItem;
  79. @property int selectionH;
  80. @property NSMutableArray * departments;
  81.  
  82. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement