gowtham gowtham - 3 months ago 26
Objective-C Question

TableView reload data is not working when it is called from other class

I have two class ,

class A
with container and
class B
I have a
which is embedded with the container.
Initially when loading data the
is loading properly when I choose different button in the
I did reloading in
class B
for which table reloading is not happening!

Class A with Container

@implementation UpgradeVCViewController
int flag = nil;

- (void)viewDidLoad {

[super viewDidLoad];
_containerView.alpha = 1.0;
// Do any additional setup after loading the view.
HHSlideView * slideView = [[HHSlideView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height -64) ];
slideView.delegate = self;

[_iconView addSubview:slideView];
[self.view addSubview:_containerView];

-(NSInteger)numberOfSlideItemsInSlideView:(HHSlideView *)slideView
return 3;

-(NSArray *)namesOfSlideItemsInSlideView:(HHSlideView *)slideView
NSArray *items = [[NSArray alloc]initWithObjects:@"PREMIUM ECONOMY",@"BUSINESS",@"FIRST", nil];
return items;


- (void)slideView:(HHSlideView *)slideView didSelectItemAtIndex:(NSInteger)index {
NSLog(@" index %li", index);

flag = index ;

if(flag == 1 || flag == 2)
SampleTableViewController * obj = [[SampleTableViewController alloc]init];

[obj.reloadtable reloadData];


Class B


[self.reloadtable reloadData];



You need to use NSNotificationCentre for reload tablview in containerView(class B).


 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(reloadTablViewWithNotification:) name:@"reloadTableView" object:nil];

-(void)reloadTablViewWithNotification:(NSNotification *)notification{
    NSLog(@"%@",[notification object]); // prints "Your object"
// here you can reload your tableview

// post when your need

[[NSNotificationCenter defaultCenter]postNotificationName:@"reloadTableView" object:@"Your object"];