'play sound in xylophone project
I try to make a Xylophone. I added my Sound file by dragging the file into my XCode project and i made sure 'Copy items if needed' is checked. I wrote the code. I connected 7 buttons to the keyPressed function. I set the names of the sound files and the names of the buttons to be the same. When I run the code and press any key, it gives this error and no sound is playing. I'm sure the sound files are also included because when I click on show in Finder, the audio files are in the project. I don't know what I did wrong.
Solution 1:[1]
When you just drag the sounds file into XCode it won't work. You need to create a new group from the file of your code related to the sounds (mine was ViewController in this case.) Then you can drag the sounds into that new file. Thus, you target the audio files.

Solution 2:[2]
I found the cause of the error. When I change Button's style Plain to Default in Inspector, it works without any problem.

When you wanna add sounds to XCode the safest way is to do, first you should create a new group by right clickin to ViewController. This will create a new file then you can drag your sounds (.wav / .mp3) into that file. While you doing that you need to target them.
After you drag and target them, you should see like this in the inspector when you click each of the sounds:
If you wont change the button style plain to default it wont work whatever you carefully drag the sounds into XCode. I know it's stupid but it should be like this. Otherwise when you run the project and click on any button it would give an error like that:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MelisYaz?c? |
| Solution 2 | MelisYaz?c? |



