在以下代码中
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]);
我正在打印文件的保留计数在发布前为 4,在发布后为 3。提前致谢