PDA

View Full Version : [iPhone] Accessing App Delegates properties




rand0m3r
Jun 20, 2008, 08:55 PM
hi. say if i have a property inside my app delegate such as an int. how will i be able to access this property from another class?

i tried setting IBOutlet from my other classes to the App Delegate, but Interface Builder doesn't let me make the connection with ctrl + drag click.



admanimal
Jun 20, 2008, 09:28 PM
In Interface Builder, just make sure that you have an App Delegate object that is set as the File Owner's delegate. Then in the code you can use:

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

to get the AppDelegate and access its properties.

rand0m3r
Jun 20, 2008, 10:07 PM
thanks.