[iPhone] Accessing App Delegates properties

Discussion in 'Mac Programming' started by rand0m3r, Jun 20, 2008.

  1. macrumors regular

    Joined:
    Jun 30, 2006
    #1
    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.
     
  2. macrumors 68040

    Joined:
    Apr 22, 2005
    #2
    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.
     
  3. thread starter macrumors regular

    Joined:
    Jun 30, 2006

Share This Page