音を扱うクラスを作りました。しかし、私は音を止めるのに問題がありますか?playSoundからstopSoundAudioServicesDisposeSystemSoundID(soundID)に変数を送信できません。これをどのように処理しますか?本当にインスタンス化したくないのですか、それともインスタンス化する必要がありますか?
@implementation SoundPlayer
+(void)playSound:(NSString *)filename ofType:(NSString *)extension {
SystemSoundID soundID;
NSString *soundFile = [[NSBundle mainBundle] pathForResource:filename ofType:extension];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:soundFile], &soundID);
AudioServicesPlaySystemSound(soundID); // error - soundID is undeclared
}
+(void)stopSound
{
AudioServicesDisposeSystemSoundID(soundID);
}
@end