I am new in iphone development and i needed a array which i use to access in different class so my senior told me that you should declare in App delegate and access it another class in which it require, so i wrote line for that
MyAppAppDelegate * appObject =
(MyAppAppDelegate*)[[UIApplication sharedApplication]delegate];
I done my task successfully but i couldn’t get it 100%. Someone tell that why we use this and in what exactly situation in which we’ve to use this?
AppDelegateis loaded first when you run your application as it contains window. So, the variable and objects you want to access throughout your project is declared inAppDelegate. You just have to create an instance and you can access all the objects inAppDelegate.