Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

FredAkbar

macrumors 6502a
Original poster
Jan 18, 2003
660
0
San Francisco, CA
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:
Code:
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. ***
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.