Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sujithkrishnan

macrumors 6502
Original poster
May 9, 2008
265
0
Bangalore
Hi all..


Folowing is a custom View for SPLASH SCREEN what i created....

In my main Window i am loading this view for busy state..

But i am getting lmem-leak on the line

[window addSubView:splashScreenObject];

Instruments is not showing where in SplashScreen.m the leak is...

Kindly help me with where i went wrong in following code...

Code:
//

#import "SplashScreen.h"


@implementation SplashScreen

-(id)initWithImageNamed:(NSString*)imageName backgroundColor:(UIColor*)bgColor
{
	if(self  = [super initWithFrame:[UIScreen mainScreen].applicationFrame])
	{
		self.backgroundColor = bgColor;
		UIActivityIndicatorView *actView =[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
		[actView startAnimating];
		actView.center = CGPointMake(130.0,230.0);
		[self addSubview:actView];
		[actView release];
		
		
		UIImage *splashImage = [UIImage imageNamed:imageName];
		UIImageView *splashImageView = [[UIImageView alloc]initWithImage:splashImage];
		CGPoint splashImageCenterPoint  = CGPointMake([UIScreen mainScreen].applicationFrame.size.width/2.0,
													  [UIScreen mainScreen].applicationFrame.size.height - [splashImage size].height/2.0);
		
		splashImageView.center = splashImageCenterPoint; 
		[self addSubview:splashImageView];
		[splashImageView release];
		
		UILabel *loadingLabel = [[UILabel alloc]initWithFrame:CGRectMake(125.0,220.0,80.0,30.0)];
		loadingLabel.text = @"Loading...";
		
		loadingLabel.textColor = [UIColor grayColor];
		loadingLabel.backgroundColor= [bgColor colorWithAlphaComponent:0.0];
		//loadingLabel.shadowOffset = CGSizeMake(1.0,1.0);
		//loadingLabel.shadowColor = [UIColor blackColor];
		[self addSubview:loadingLabel];
		[loadingLabel release];
	
		return self;
	}
	return nil;
}

-(void)dealloc
{
	
	[super dealloc];
}


@end
 
The leak is probably with the splashScreenObject itself. If it were in the init routine, Instruments would have pointed to the line in that routine that caused the problem.

Are you releasing splashScreenObject after adding it to the subview?

Tom
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.