views:

44

answers:

2

Hi I have an iphone application in which I am fetching & parsing data in in applicationDidFinishLaunching. Now I want to transfer this fetched data which is in one NSMutableArray to my first view controller to display it there.

Whats the best way of doing this...

+1  A: 

You can past it through the init like initWithDataArray: , I think that is good enough.

Another solution, which imo is worse, is parsing the AppDelegate to the ViewController and then you can call : appDelegate.dataArray but it will leak out too much information

vodkhang
A: 

Application Delegate is what i prefer in this case.

//Declare NSMutableArray object in AppDelegate.h ,Now property & synthesize it

//Store your data in NSMutableArray object

//Create ApplicationDelegate object any your View Controller Class

yourApplicationAppDelegate *appDelegate;

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

Now you can access NSMutableArray object through appDelegate any where in your application

raaz