Why Release


#1

This memory management thing is getting a little rough on me. When you add the UIScrollView in Chapter 6 there is a [scrollView release]; right after the subview is added. I read on to finish the chapter and I read that children are not supposed to retain their parents, and this is exactly what I thought was happening when the scrollView was released. So basically my question here is when the scrollView is allocated and initialized it has a retain count of 1, then it is added as a subview so it goes to 2 right? That is why it is released later so it will go back to 1 and then be released when its parent is right? Or am I totally off my rocker here?


#2

That’s it exactly. :slight_smile: