Search code examples
iostableviewappdelegatereloaddata

How to reload table view from another view controller via appDelegate in iOS Objective C


I'm trying to reload my SingleGrid's UITableView from my FirstViewController. UITableView's declaration is IBOutlet and singleGrid variable declared in my AppDelegate. I want to reload singleGrid's UITableView from FirstViewController.Table view name singleGridTable isn't coming after dot.

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

[appDelegate.singleGrid.singleGridTable reloadData]

Solution

  • Make sure you have declared singleGrid as a property in your appdelegate.h like

    @property (nonatomic, strong) SingleGridViewController * SingleGrid;
    

    Those properties which are declared in .h files are public otherwise they are private and you can't access them in other classes.

    Also make sure singleGridTable is also declared as property in your .h file.

    @property (nonatomic, weak) IBOutlet UITableView * singleGridTable;