release viewcontroller after presenting modally
Posted
by Jonathan
on Stack Overflow
See other posts from Stack Overflow
or by Jonathan
Published on 2010-05-16T08:04:53Z
Indexed on
2010/05/16
8:10 UTC
Read the original article
Hit count: 229
I was watching CS193P Stanford course on Itunes, and in one of the lectures a demo was given and There it was said you could present the viewcontroller modally and then release it. Roughly like this (I know this isn't perfect but I'm on my PC atm)
[self.view presentcontentmodally:myVC]
[myVC release];
However this seems to produce problems. If I put a NSLog(@"%d", [myVC retainCount])
between those two lines then it returns 2 implying it is ok to release. However when I dismiss the myVC
the app crashes. Nothing in the NSlog and the debugger won't show where it stopped.
But I used malloc-history or something that some blog said would help. And found that it was the myVC.
So should I be releasing myVC?
(also when the modalVC has been dissmissed should the app's memory usuage go back to before the modalVC was presented?)
© Stack Overflow or respective owner