Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-02-2009, 12:54 PM   #2 (permalink)
smasher
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

addSubview also increased the retain count of the subview. Until you remove the subviews from m_contentView OR m_contentView is destroyed, the subviews will not be released by the superview.

I would also move your [m_bkg[i] release] up futher in the code, closer to where you init the imageviews; then you don't have to release them later, just get them removed from the superview or release the superview.

This is how you can add the subviews and release them right away:

Code:
	for (int i=0;i<NB_BKG;i++)
	{
		m_bkg[i]=[[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 480.0, 320.0)];
		[m_contentView addSubview:m_bkg[i]];
		[m_bkg[i] release];
		[m_bkg[i] setImage:[TestViewCtrlAppDelegate thumbnailImage:[NSString stringWithFormat:@"test%02d",i]]];

	}

In fact, I'm not sure you need the m_bkg array at all, if its only purpose was to release the imageviews. Maybe it has another purpose?
__________________

Free Games!
smasher is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,722
Threads: 89,181
Posts: 380,503
Top Poster: BrianSlick (7,124)
Welcome to our newest member, idny99
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:48 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.