I’m creating IBOutlets by dragging a UI component from within the XIB editor into my view controller’s header file. I’m dragging and dropping within the curly braces so that they are simply treated as instance variables and not properties. However, in spite of this I noticed release statements in my viewDidUnload and dealloc methods. Isn’t this unnecessary? Like I said, these are not properties I’m creating. Why is the code being generated to release these objects when there is no retain, alloc, copy etc ?
I’m creating IBOutlets by dragging a UI component from within the XIB editor into
Share
On iOS, if an outlet is declared to be an ivar instead of a property, you are responsible for releasing it at the appropriate times (i.e. in
-deallocand in-viewDidUnload. You should also set them tonilin the latter.)This is due to a quirk of memory management on iOS. Regardless, my personal preference is to avoid using
readwriteproperties for outlets, because IMHO it breaks the view controller’s encapsulation in a bad way.