J'ai créé une classe pour la gestion des sons. Mais j'ai un problème pour arrêter le son? Je ne peux pas envoyer de variable de playSound à stopSound AudioServicesDisposeSystemSoundID (soundID). Comment gérer cela? Je ne veux vraiment pas l'instancier ou je dois le faire?Variable de méthode statique
@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
et comment puis-je déclarer statique param? – alexhajdu
'@interface TheClass: NSObject + (int) nombre; @ end' voir: http://stackoverflow.com/questions/6035824/objective-c-static-class-variables – cleverbit