0

I'm using SWRevealViewController to get the side menu to show different content based on which tab the user is currently on. I've created a global variable in called location in AppDelegate to find out where the user is. For my sidebar, I'm using this condition to change the content:

- (void)viewWillAppear:(BOOL)animated {
[super viewDidAppear:animated];

AppDelegate *del=(AppDelegate*)[[UIApplication sharedApplication] delegate];

if ([del.location  isEqualToString: @"Secure"]){
self.menu = [NSMutableArray
             arrayWithObjects:@"secure1",@"secure2",@"secure3",@"secure4",@"secure5", nil];
self.menu2 = [NSMutableArray
              arrayWithObjects:@"s1",@"s2",@"s3",nil];
    NSLog(@"THIS IS %@ menu",del.location);
}
else if ([del.location  isEqualToString: @"Employee"]){
    self.menu = [NSMutableArray
                 arrayWithObjects:@"emp1",@"emp2",@"emp3",@"emp4",@"emp5",@"emp6", nil];
    self.menu2 = [NSMutableArray
                  arrayWithObjects:@"e1",@"e2",@"e3",nil];
    NSLog(@"THIS IS %@ menu",del.location);
}
else if ([del.location  isEqualToString: @"Patient"]){
    self.menu = [NSMutableArray
                 arrayWithObjects:@"patient1",@"patient2",@"patient3",@"patient4",@"patient5",@"patient6", nil];
    self.menu2 = [NSMutableArray
                  arrayWithObjects:@"p1",nil];
    NSLog(@"THIS IS %@ menu",del.location);
}
}

It seems to be working as the NSLog statements all come out correctly, but the content for menu and menu2 still do not change. Where am I going wrong?

Bhavesh Nayi
  • 3,626
  • 1
  • 27
  • 42

1 Answers1

0

I wasn't adding the

[self.tableView reload]; 

after closing the if-statement, and instead added it under cellForRowAtIndexPath (which lead the cells to constantly reload, but not the table -- if my understanding is correct.)

Added it in the viewWillAppear after closing my if-statement and problem solved.

Thanks to Anbu.Karthik for pointing it out!

Bhavesh Nayi
  • 3,626
  • 1
  • 27
  • 42