Cocoa: trouble playing sounds in my app

Discussion in 'Mac Programming' started by FredAkbar, Dec 22, 2004.

  1. FredAkbar macrumors 6502a


    Jan 18, 2003
    Santa Barbara, 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:
    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 @"./" 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. ***

Share This Page