iOS Development Discussion on developing apps for the iOS platform.

Soundboard problem please help


Post Reply New Thread Subscribe

 
Thread Tools
Dale O Shea

 
Member Since: Mar 09, 2012
Posts: 10
Dale O Shea is on a distinguished road

Dale O Shea is offline
Hey guys I'm having a small problem connecting the code for the sound to the button.

I created a project "Tabbed application" and then i added an image to the first and second view, then i added audio.toolbox.framework in the "link binary with library" section under build phases section. Then created round rect buttons and put them where they needed to be. Heres when the problem starts, when i click on one of the buttons and press ctrl a light blue line appears and i drag it to the code for that button in the .m file but it won't connect to it nothing happens. Could somebody please help me with this ?

Here the code i wrote for the button but I'm pretty sure its fine
Code:
-(IBAction)sound1 {
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound1", CFSTR ("wav"), NULL);
    
    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);
}
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 143
Mark FX has a spectacular aura about

Mark FX is offline
The implementation of your IBAction method is incorrect, all IBaction methods should
follow the example below.

Code:
//in your .h interface file you should declare your IBAction method like this

- (IBAction)methodName:(id)sender;

//In your .m implementation file you then implement the above method like this.

- (IBAction)methodName:(id)sender
{
      //Your code goes here
}
In your example, your missing the (id)sender part of the declaration, which every
IBAction method should have.

Save the files before moving over to Interface Builder, then control drag from the Button to
the controller class's Object cube, and select the IBAction method.

Also I noticed your using the AudioToolkit Framework for your sound playing methods, if
your only wanting to play short system type sounds, or audio files in a simple playback
utility, you might want to consider the NSSound class.

Hope this helps.

Regards Mark
QUOTE Thanks

Post Reply New Thread Subscribe


« Unit testing initialization code | A problem with View disappear? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Problem with copy and paste that does not paste the more recent copy? pcortez Switcher Hangout 22 08-01-2012 01:28 PM
diagnosing kernel task/CPU problem on Macbook Air nick_harambee Apple Notebooks 9 08-20-2011 07:20 AM
could this be an OS problem? Anyuta OS X - Operating System 0 11-22-2010 04:50 PM
Strange iweb problem Anyuta Web Design and Hosting 0 09-27-2010 12:46 PM
2009 MBP - Possible Trackpad Problem tricky10 Apple Notebooks 6 09-09-2010 07:01 AM

All times are GMT -4. The time now is 05:42 AM.

Powered by vBulletin
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?