0

In Following code

 NSURL *file = [[NSURL alloc] initFileURLWithPath: [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:soundName]];
     //        NSData *data = [NSData dataWithContentsOfURL:file];
     myExampleSound1 =[[AVAudioPlayer alloc] initWithContentsOfURL:file error:nil];
     myExampleSound1.volume=0.9;
     [myExampleSound1 prepareToPlay];
     myExampleSound1.delegate = self;
     [myExampleSound1 play];
     [soundsArray addObject:myExampleSound1];

     NSLog(@"RETAIN COUNT BEFORE RELEASE file = %d, myExampleSound1=%d, soundsArray=%d", [file retainCount],[myExampleSound1 retainCount], [soundsArray retainCount]);
     [file release];
     NSLog(@"RETAIN COUNT AFTER RELEASE file = %d, myExampleSound1=%d, soundsArray=%d", [file retainCount],[myExampleSound1 retainCount], [soundsArray retainCount]);

I am printin the retain count of file is 4 before release and 3 after release. Thanks in advance

Shashank Kulshrestha
  • 1,959
  • 17
  • 29
  • 6
    1. What's your question? 2. Don't use retainCount. –  Mar 25 '13 at 11:33
  • 3
    What guide did you read that said to use `retainCount`? I want to find the source so I can correct it if I can. It should never be used to determine object lifetimes. It shouldn't really be used at all. – dreamlax Mar 25 '13 at 11:38
  • 2
    http://whentouseretaincount.com – Guillaume Mar 25 '13 at 11:46

0 Answers0