View Full Version : Cocoa: trouble playing sounds in my app

Dec 23, 2004, 12:10 AM
I'm writing a simple text-adventure game in Objective C and Cocoa. I read Apple's Obj-C page on the NSSound class and used this code to play a test sound file:
NSSound *mySound = [[NSSound alloc] initWithContentsOfFile:@"/path/to/soundfile.aiff" byReference:YES];
[mySound play];
However, when I made it so that the sound file is copied into my app when I build it, and use @"./MyApp.app/Contents/Resources/soundfile.aiff" as the path, it works when I hit Build & Run but not when I hit Build and then run the app by itself. I've checked to make sure that the sound file was in fact copied to the Resources folder inside my app. Does anyone know why this isn't working, or if I'm using the wrong code? Thanks...

*** edit: never mind, figured it out. ***