keep reference to tabbar after viewDidUnload?

I am trying to disable all the tabs of a tab bar except the first tab. I came up with this code:

-(void)disableMainTabBar{

        [self setSelectedIndex:0];
        for(UITabBarItem *item in self.mainTabBar.items){
            if(self.firstTabBarItem != 0)  item.enabled = false;
            self.firstTabBarItem++;
        }
}

This code is in the UITabBarControllers class file. Although this works when called from its own class when I call this function from another class it doesn't work. When I nslog the tabbar whenever the above method is called when this method gets called from another class its shows NULL. How can I make it keep a reference to the tabbar after viewDidUnload is called?

I'm new to iOS development so please bear with me.

Thanks!

-Shredder2794

Answers


you have to import the UITabBarController class in the other class where you want to call the method and after creating it's instance call the method using that instance this will defiantly solved your problem of NULL.


Need Your Help

Recommend .NET data access layer/middle tier

.net design-patterns data-access-layer data-access

I'm currently creating an MVC application that will likely to expand to include a silverlight, wpf and possible windows phone all using the same data.

Postgres - how to return rows with 0 count for missing data?

python database postgresql left-join generate-series

I have unevenly distributed data(wrt date) for a few years (2003-2008). I want to query data for a given set of start and end date, grouping the data by any of the supported intervals (day, week, m...