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

Sergio10

macrumors regular
Original poster
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.
 
Either retain the NSNumber, or remove the [tmpValue release] - it's not necessary since the object is autoreleased.
 
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.
 
how can you tell from this code if the NSNumber instance is being autoreleased? is it because NSNumber is part of the foundation framework?
 
Do you see 'alloc', 'copy', or 'new' anywhere in the name of the method used to create it? If not, treat it as autoreleased.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.