Skip to content

Tag Archives: Objective-C

Tadaaaa! Sound abspielen in Cocoa/Objective-C

Hier eine Beispiel-Implementation einer Methode, die eine Sound-Datei abspielen soll. Der Typ der Datei ist dabei relativ egal, sie muss von Apple einfach unterstützt werden. – (void) playAlertSound:(id)soundFile{ NSSound *sound = [[NSSound alloc] initWithContentsOfFile:soundFile byReference: YES]; [sound play]; } Nun können wir die Methode überall relativ simpel aufrufen: [self playAlertSound:[NSString stringWithFormat:@"%@/authoriz.mp3", [[NSBundle mainBundle] resourcePath]]]; [[NSBundle [...]

Optimized by SEO Ultimate