Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARC and Interface Builder

I have an interesting question about interface builder and ARC. I am building a view controller that will be initialized with a xib. I use the tap-and-drag capability of interface builder to create necessary property outlets for my xib. This initalizes the property as (weak, nonatomic). Sounds fine to me.

What's throwing me off is that lines such as [self setCategoryButton:nil]; are automatically added to viewDidUnload. I understand and used this before ARC. However, since these are weak references, wouldn't they automatically be cleared when the view unloads?

I suppose I could see the value in nil-ing these properties if those views are retained by other objects, but that seems an unusual case to me... Just wanted to get further feedback on the point.

Thanks,

Kurt

like image 629
Kurt Spindler Avatar asked Dec 27 '22 04:12

Kurt Spindler


1 Answers

I filed a bug on this a while back, and the response that I got was that this is intentional behavior. Since Xcode cannot verify that there are no other strong references to the view, it cannot actually guarantee that the weak pointer would be automatically cleared in -viewDidUnload. Thus, they clear it for you.

Personally, I think this is a lame reason, but that's the reason that was given.

like image 79
BJ Homer Avatar answered Jan 11 '23 19:01

BJ Homer