- (id) init
{
[super initWithNibName : nil
bundle : nil];
UITabBarItem *tbi = [self tabBarItem];
[tbi setTitle : @"Hypnosis"];
UIImage *i = [UIImage imageNamed : @"Hypno.png"];
[tbi setImage : i];
return self;
}
Consider the above sample code, my questions are :
1
There is a “setImage” method call, but I cannot find the corresponding “Image” property
in documentation.
2
UIImage *i is being assigned by the statement “[tbi setImage : i]” to the Image property.
Does “*i” being retained by tbi? If so, should we release “i” immediately after the assignment ?
Hope that some knowledgeable person would help me to find the answers.
there doesn’t need to be an
imageproperty declared for a class to have asetImage:method–a property can be implied to exist by the existence of setters/getters.iwill be retained by the TabBarItem–that’s the responsibility of the setter API. This is standard behavior. Finally, do not releaseiafter callingsetImage:. You do not have an owning reference toisince it was returned from a factory method, not an [ [ alloc ] init ] invocation. HTH