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

Sergio10

macrumors regular
Original poster
Oct 3, 2007
137
0
Hi,
This slider's control action function:
Code:
- (IBAction)dragSlider:(id)sender
{
	NSNumber *tmpValue = nil;
	
	if(_isChecked == YES)
	{
		// double value
		tmpValue = [NSNumber numberWithInt: [ sender intValue ] *2 ];
		[ _position setStringValue: [ tmpValue stringValue ] ];
	}
	else
	{
		tmpValue = [NSNumber numberWithInt: [ sender intValue ] ];
		[ _position setStringValue: [ tmpValue stringValue ] ];
	}
	
	// free resources
	[tmpValue release];
}
Why does application is hang?

Thanks.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Either retain the NSNumber, or remove the [tmpValue release] - it's not necessary since the object is autoreleased.
 

Sergio10

macrumors regular
Original poster
Oct 3, 2007
137
0
You mean garbage collector is responsible for memory management?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
No, your tmpValue is an autoreleased object, which means it gets released automatically later on by the autorelease pool. If you're not familiar with this (very important) concept, you should read through this and the other articles on memory management.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.