What should be the retain Count here + iPhone -


i have following lines of code in program

visitwebsitevc *visitwebsite          = [[visitwebsitevc alloc] initwithnibname:@"visitwebsitevc" bundle:nil]; nslog(@"retain count :%i",[visitwebsite retaincount]); [self.navigationcontroller pushviewcontroller:visitwebsite animated:yes]; nslog(@"retain count :%i",[visitwebsite retaincount]); [visitwebsite release]; 

in console see print statement as

retain count :1
retain count :5

i not getting why line after pushing viewcontroller returning retaincount of viewcontroller 5, when must 2.

you don't want rely on retain count anything. there's sorts of stuff going on behind scenes when push view controller (the view instantiated, may mean loading xib, there bunch of autorelease calls haven't fired yet). it's pretty dangerous way check memory usage.

as why it's 5 , not 2, said earlier, it's related unresolved autorelease pools. if check retaincount in viewdidappear, or, better yet, after initialization calls have resolved, might closer 2.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -