views:

416

answers:

1

I've always been baffled about the strange coupling in the iPhone API -- in particular, with the UIViewController, which has hard-coded references to a UITabBarItem, UITabBarController, etc.

So, you end up adding a UIViewController to a UITabBarController, which in turn queries the UIViewController as to what should be displayed on the UITabBar (through the UIViewController's tabBarItem property).

Why doesn't it go UITabBarController->UITabBarItem->UIViewController? It seems so obvious.

Does anyone else think this is screwy?

+2  A: 

The UITabBarItem is actually more of a button than anything else. It's the thing you tap on to select a tab. Since it's a button, it shouldn't "own" the UIViewController that it displays. Instead, it sends a message to the UITabBarController to switch to the UIViewController as indicated by the selected tab bar item.

Also, please be careful with the term "hard-coded." Using that term implies that the values cannot be changed. In the case of UITabBarController, these are properties that CAN and DO change.

August