I am an experienced programmer in C, yet not objective c. I am trying to help my friend out by giving him this piece of code in objective c. By the way, this is for an iPhone application. I have all foundations necessary, and as you can see, have declared my sound as soundA, using the – (IBAction) method… In addition, the sound is a simply .wav file no larger than 100 kb.
- (IBAction)soundA:(id)sender {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle,
(CFStringRef) @"soundA", CFSTR ("wav"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
Any help is greatly appreciated! Thanks so much.
- Kook
Maybe try changing it from an Unsigned Int to
SystemSoundIDOr go with a more Objective-C approach: