J'ai écrit un pas cher & carte son de bonne humeur pour mon Mac, et je joue les différents sons avec NSSound comme ceci:Comment effacer un objet NSSound
-(void)play:(NSSound *)soundEffect:(BOOL)stopIfPlaying {
BOOL wasPlaying = FALSE;
if([nowPlaying isPlaying]) {
[nowPlaying stop];
wasPlaying = TRUE;
}
if(soundEffect != nowPlaying)
{
[soundEffect play];
nowPlaying = soundEffect;
} else if(soundEffect == nowPlaying && ![nowPlaying isPlaying] && !wasPlaying) {
[nowPlaying play];
}
}
Plutôt que de simplement arrêter mort, je Je voudrais l'éteindre en quelques secondes.
J'ai juste essayé ce Chris, la fonction Sleep a mis tout l'ordinateur portable en veille, ce qui m'a fait rire. sleep fonctionne correctement, sauf le paramètre qu'il faut en secondes plutôt qu'en millisecondes. –
Malédictions sur votre clé de décalage errant! –