0

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?

Vin
  • 10,517
  • 10
  • 58
  • 71
Ghostino Doggio
  • 351
  • 1
  • 4
  • 11
  • have you tried debugging, whether control goes to data source and delegate methods of table view or not? – rishi Apr 24 '12 at 06:16
  • Do you have reference to Current GridView controller in your app delegate. I mean is `gridViewController` actually the controller which is present at the screen? – Adil Soomro Apr 24 '12 at 06:21
  • Feels like I need another 'ask a question' about how to debug, or just quit. haha! thanks. – Ghostino Doggio Apr 24 '12 at 06:26
  • Adil Soomro. Yeah, It actually display on screen in the runtime. but I didn't make it in storyboards. – Ghostino Doggio Apr 24 '12 at 06:30

1 Answers1

2

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];
}
Maksim
  • 2,054
  • 3
  • 17
  • 33