Reputation: 772
So in my appDelegate I have an array of events, like this:
AppDelegate.m
#import "AppDelegate.h"
#import "ListViewController.h"
#import "Event.h"
#import <RestKit/RestKit.h>
@implementation AppDelegate{
NSMutableArray *events;
/* for test data */
NSMutableArray *titles;
}
@synthesize window = _window; ...
And I want to acces this events array in a viewcontroller like so:
MapViewController.m
#imports ...
...
-(void) viewDidLoad{
[super viewDidLoad];
[worldView addAnnotation:[ACCES_EVENTS_HERE objectAtIndex:int]; // <------
NSLog(@"Loadded the view for MapViewController");
}
How do I do this? And secondly, is there a better place to add the events on the map then viewDidLoaD? (The events will come from a database so there will be lots of events)
Upvotes: 0
Views: 102
Reputation: 11174
I think its a bad idea to store variables like this on the app delegate, but if you need access you can get a reference with
id<UIApplicationDelegate> myDelegate = [[UIApplication sharedApplication] delegate]
you will need to cast this to your delegates class to access variables though
Upvotes: 1