Q:

iphone application for tabbar

How can I defined and check the alreadySelectedSpecificTab and viewControllerNotToAllow in 
my application. anyone give me one example for that.
Actuly I would like to do something. like. When second tab is selected that time if we select second tab is not selected only remaing tab is to be selected.
thats why I used the following code. 
please reply
- (BOOL)tabBarController:(UITabBarController *)tabBarControllers shouldSelectViewController:(UIViewController *)viewController
{
if(alreadySelectedSpecificTab)
        {
             if([viewController isEqual:viewControllerNotToAllow])
                  return NO;
        }
        return YES;
}

A:

Create some properties in your class
and keep track of what you want denied and what you dont want denied.
id currentlySelected; //This will hold the address of the selected view
id dontAllowSelection; //This will hold the address of the Denied view

- (BOOL)tabBarController:(UITabBarController *)tabBarControllers shouldSelectViewController:(UIViewController *)viewController
{
    if (dontAllowSelection != nil &&             //If it is nil, we will skip it.
         dontAllowSelection == viewController)   //If the selected view is Denied return NO
    {
        return NO;
    }
    currentlySelected = viewController;

    if (currentlySelected == someViewIWantToDisableOtherFor) //Any logic can go here to enable the Denied View.
    {
        dontAllowSelection = anotherViewIWantDisabled; //Set my denied view.
    }
    else
    {
        dontAllowSelection = nil; //Unsed the Denial.
    }

    return YES;
}

