Question

I'm relatively new to IOS programming. I've finished a class where all the programming is done without ARC and I had a memory management problem that I was hoping could be clarified.

My situation is this: I have an app where a "parent" view controller holds on to another "child" view controller that it will push. So when this child view is pushed and then popped, it will not be deallocated because the parent view holds on to it. But even so, I think this child view still calls release on all of its properties when it is popped. I have (nonatomic, retain) properties inside it, and it must be calling release on those properties because those fields end up being deallocated and are null when the child view is popped, even though that child view controller itself still exists.

I thought that as long as I held onto the child view controller in the prior view controller, it would not release any of its properties even if it was popped, but I guess that's not the case. Am I correct about this? I couldn't find one, but is there a reference page that states everything that is called when a view is popped?

Was it helpful?

Solution

That shouldn't be the case. When you pop a view controller, it will decrement the retain count of the child by one. But the child controller will not release its elementes until its dealloc method is called when its retain reaches zero. if you are correctly retaining it in the parent then it should not be dealloc'd.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top