Can't find in Documentation?


Pretty easy answer i suppose…

but I’m trying to find where in the docs does the UITabBarItem show it can do this:

[tbi setImage:i]

I did a search for the obvious…UITabBarItem, but nowhere does it show the setImage message.

any thoughts?



It’s a good question.

Nothing likely in UITabBarItem, so we start up the inheritance hierarchy:

Looking at UIBarItem we don’t see “setImage”…BUT we see a property named image. Clicking that link shows:

Nothing special there, but we know that when a property is synthesized, both a getter (-image) and a setter (-setImage:) are created behind the scenes for us (unless the property attributes dictate otherwise or we create our own).

Even easier than all of that? (You’ll love this.) Option-click on “setImage” in that line of code:

The result? A little pop-up with:

Name: setImage:
Declaration: @property(nonatomic, retain) UIImage *image
Availability: iOS (2.0 and later)
Abstract: The image used to represent the item.
Declared In: UIBarItem.h
Reference: UIBarItem Class Reference
So the answer is: -setImage: comes from the synthesized image property in UIBarItem.

For extra credit: option-click on item in that line of code. Then command-click (not option) setImage, item, and UIImage (one at a time).