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
- NIB loader (alloc | retain) & autorelease all top-level objects. So it will be dealloc on runloop turn ends without additional retain.
- Connecting IBOutlets are done with KVC.
- KVC uses accessor method primarily.
- KVC uses setValue:forKey secondarily. And the IBOutlet will be handled by this method because there's no declared property or access method.
- setValue:forKey retains the new value object.
- setValue:forKey releases the old value object.
- 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.
- If the object connected another IBOutlet like the IBOutlet, it should be released once more to be dealloc.