Setting Properties of a View Controller

Discussion in 'iOS Programming' started by Kizmar, Nov 4, 2010.

  1. Kizmar macrumors newbie

    Kizmar

    Joined:
    Oct 28, 2010
    #1
    New to iOS development...

    I've created an EntityListViewController that I would like to use to display different lists based on a listType property of the view controller.

    I'd like to use this view with a Tab Bar Control. So far I've managed to figure out that I need to use didSelectViewController in the app delegate, and I can tell which tab is active by inspecting the tag. Set an alert, it pops up when I select the tab I wanted the alert to pop on. Good... but...

    My question is: At this point I should know which view controller is currently active. How do I now set the listType property while I'm still in the didSelectViewController method?

    I'm a .NET developer, so my first instinct is to create an instance of EntityListViewController and set it to (EntityListViewController)viewController, but that doesn't work. :)

    Just need to be pointed in the right direction here. Thanks.

    This is what I'm referring to (for clarity):
    Code:
    // Optional UITabBarControllerDelegate method.
    - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    	
    	// If this is tab 5, set the listType property of the viewController to XX 
    	if (viewController.tabBarItem.tag == 5)
    	{
    		// Set a property of the currently selected view
    	}
    }
     
  2. jvaneat macrumors newbie

    Joined:
    Nov 4, 2010
    Location:
    Colorado
    #2
    Try

    Code:
    ((EntityListViewController *)viewController).myProperty
    
     
  3. Kizmar thread starter macrumors newbie

    Kizmar

    Joined:
    Oct 28, 2010
    #3
    Perfect. That's exactly what I needed! Thanks. :)
     

Share This Page