I am creating a new UIViewController with the below code
GameViewController *temp = [[GameViewController alloc] initWithNibName:@\"GameViewController\" bundle:ni
In GameViewController have you released your background music as
- (void)viewDidLoad{
//Other nils
self.backgroundMusic = nil;
}
- (void)dealloc{
//Other releases
[backgroundMusic release];
[super dealloc];
}
Never use retainCount, it does not work the way you think it does.
If you need to see where retains, releases and autoreleases occur for an object use instruments:
Run in instruments, in Allocations set "Record reference counts" on on (you have to stop recording to set the option). Cause the picker to run, stop recording, search for there ivar (datePickerView), drill down and you will be able to see where all retains, releases and autoreleases occurred.
I advise you never using retainCount because it usually gives false information about the actual retaincount of your object!!!!
Just follow the appropiate memory management practices!!!! It's very simple really, just follow the NARC principle, release only the objects that have these words: New Alloc Retain Copy. NARC! :)
I strongly advise you using the memory leaks tool from instruments that tells you which objects were not released and which objects where released and you are trying to access.
"You should never use retainCount
". Here is a very good description, why to not:
stackoverflow