How do I play sound with (IBAction)playsound:(id)sender

I am trying to simply place a sound with its button. I have reached a stopping point due to the lack of understanding. I tried for about 4 hours trying to fix this but, to no avail found nothing. can someone help me? I'm getting the error, "use of undeclared identifier 'soundFile'" here is my .m file..

//  FirstViewController.m
//  simpleApp
//  Created by Abby Russell on 11/29/13.
//  Copyright (c) 2013 Abby Russell. All rights reserved.

#import "FirstViewController.h"

@interface FirstViewController ()


@implementation FirstViewController

- (void)viewDidLoad
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

- (void)didReceiveMemoryWarning
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

- (IBAction)playsound:(id)sender {
    SystemSoundID soundID;
    NSString *buttonName=[sender currentTitle];
    NSString *path = [[NSBundle mainBundle] pathForResource:buttonName ofType:@"wav"];

    AudioServicesCreateSystemSoundID((__bridge CFURLRef)
                                     [NSURL fileURLWithPath: soundFile], &


Thank you so much smart people!


soundFile needs to be an NSString path to the sound file. It appears you just entered the text "soundFile" without actually having any NSString named soundFile. Try replacing soundFile with "path".

Need Your Help

Breeze EF6 SaveChanges doesn't propagate exceptions

exception breeze entity-framework-6 savechanges

In the EFContextProvider (EF6) SaveChangesCore method, the exception handling looks like this:

How to set the specificity of a css over-ride class for XPages

css twitter-bootstrap-3 xpages override

This starts from a previous question that I asked but I think I know what needs to be done but not the How. I have this block of code that defines a pager in bootstrap and applies the bootstrap sty...