Accessing array from another class

Discussion in 'iOS Programming' started by Xentarios, Jul 23, 2008.

  1. macrumors newbie

    Joined:
    Jul 23, 2008
    #1
    I have an array in my NameAppDelegate class that I would like to access from somewhere else. What is the correct syntax to access it? I currently have the following in my viewController class and the arrayName array is set up properly in the NameAppDelegate class.

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

    NSLog([appDelegate.arrayName objectAtIndex:0]);

    Checking the console I don't see any value printed yet I can test a different array from the same file and it prints correctly.
     
  2. thread starter macrumors newbie

    Joined:
    Jul 23, 2008
    #2
    Never mind, I figured out the problem. My database wasn't initialized before control was passed to the line.
     

Share This Page