我需要一些帮助来解决这个内存泄漏问题。我正在使用 ARC。
潜在的泄漏在这条线上:
NSURL *aFileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
这是代码:
// === Check if the game should play sound === //
if (sound == YES) {
//==== PLAY THE LOOSING SOUND ====//
// Form a URL to the sound file, which in init using the Path
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *filePath = [mainBundle pathForResource:@"wrong2" ofType:@"wav"];
NSURL *aFileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
// Create a sound ID,
SystemSoundID myID;
// Register the sound
AudioServicesCreateSystemSoundID((__bridge_retained CFURLRef)aFileURL, &myID) ;
// Play the sound!
AudioServicesPlaySystemSound(myID);
}