I have GridViewController.
@interface GridViewController : UIViewController <AQGridViewDelegate, AQGridViewDataSource, LoginViewControllerDelegate, IconDownloaderDelegate, UIScrollViewDelegate> {
NSArray *objects; //main data model
NSMutableDictionary *imageDownloadsInProgress;
}
@property (nonatomic, retain) IBOutlet AQGridView *gridView;
I need to call reloadData method to my gridview.
When I call [self.gridView reloadData];
in GridViewController.m (viewDidLoad),
it reloads with no problem.
But I need to call this method in AppDelegate.m
so I import "GridViewController.h" in AppDelegate.m
#import "AppDelegate.h"
#import "GridViewController.h"
and call the method,
[gridViewController.gridView reloadData];
It's not working.
How can I call this method to GridViewController's gridView from my delegate.m?
Try to post a notification in your AppDelegate that your GridViewController will catch. In AppDelegate.m in a place there you need to call your grid reload code:
[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadGrid" object:nil];
In your GridViewController's viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadMyGrid)name:@"reloadGrid" object:nil];
In your GridViewController's viewDidUnload:
[[NSNotificationCenter defaultCenter] removeObserver:self];
And your need to add method to your GridViewController:
- (void)reloadMyGrid {
[self.gridView reloadData];
}