プロジェクトを ARC に変換しました。Xcode は、コード内のこの行を例から変更しました
soundFileURLRef = (CFURLRef) [tapSound retain];
に
soundFileURLRef = (__bridge CFURLRef) tapSound;
しかし、音は再生されません。どうしたの?
- (IBAction)buttonTapped:(UIButton *)sender {
// Create the URL for the source audio file. The URLForResource:withExtension: method is new in iOS 4.0
NSURL *tapSound = [[NSBundle mainBundle] URLForResource: @"abide" withExtension: @"aif"];
CFURLRef soundFileURLRef;
SystemSoundID soundFileObject;
// Store the URL as a CFURLRef instance
soundFileURLRef = (__bridge CFURLRef) tapSound; // I think this line is wrong
// Create a system sound object representing the sound file.
AudioServicesCreateSystemSoundID (
soundFileURLRef,
&soundFileObject
);
AudioServicesPlaySystemSound (soundFileObject);
}