views:

70

answers:

0

I know about mechanism about outlet connection during loading NIB, but I have no sure. So I'm asking some questions to ensure my knowledge. I assumed these things all true, but It's hard to find mentioning about these on reference documentation. Please point wrong and right things.

I have an IBOutlet defined like this: (Of course it's not recommended way)

@implementation
{
    IBOutlet id var1;
}
@end
  1. NIB loader (alloc | retain) & autorelease all top-level objects. So it will be dealloc on runloop turn ends without additional retain.
  2. Connecting IBOutlets are done with KVC.
  3. KVC uses accessor method primarily.
  4. KVC uses setValue:forKey secondarily. And the IBOutlet will be handled by this method because there's no declared property or access method.
  5. setValue:forKey retains the new value object.
  6. setValue:forKey releases the old value object.
  7. So top-level object connected to the IBOutlet will be retained once. So I have to release it to dealloc. This is why I must release objects connected to IBOutlet on dealloc method.
  8. If the object connected another IBOutlet like the IBOutlet, it should be released once more to be dealloc.