Staff Member

May not be related to your issue but if you go through the trouble to define properties and synthesize accessors for it, you should also take the time to reference them correctly.

Code:

[theAudio play];

doesn't.

P.S. That is why often it is recommended to name the instance variables for your properties different from the property-names themselves so you know which is which. I usually go with something like this:

I know my naming conventions are poor, I'm trying to get better at it this is only my 2nd month doing this with no programming experience

Basically I have a settings page with a uiswitch on, what I'd like to be able to do is when the switch is off the sound effects one the game stop and when you switch the switch back on the sound comes back.

Staff Member

Basically I have a settings page with a uiswitch on, what I'd like to be able to do is when the switch is off the sound effects one the game stop and when you switch the switch back on the sound comes back.

Click to expand...

Alright, that explains what you're trying to do. Now, you should explain what is actually happening. You say it's not working and I asked you to elaborate. Please do so. Are you seeing any errors or warnings at compile-time? How about run-time? Is it crashing? If so, what does the crash log say? Have you tried basic debugging? If so, what? What have you discovered? Etc. We can't do this stuff for you.

Alright, that explains what you're trying to do. Now, you should explain what is actually happening. You say it's not working and I asked you to elaborate. Please do so. Are you seeing any errors or warnings at compile-time? How about run-time? Is it crashing? If so, what does the crash log say? Have you tried basic debugging? If so, what? What have you discovered? Etc. We can't do this stuff for you.

Click to expand...

Everytime there's a collision between these 2 images the sound works fine, so I added the code like above to try and be able to stop the sound if i needed too.
I don't get any warnings, errors, crashes or anything. The app loads but when I flick the switch nothing happens.

Staff Member

I'll ask again then: what basic debugging have you done? You know, things like setting breakpoints and stepping through code. Or even NSLogs. Part of basic debugging is verifying that what you think is happening at each step is actually happening. Using skills like this is very key to troubleshooting.

And the reason I'm pushing so hard on this stuff is that if you look at your code for switchValueChanged, you may notice that it doesn't even reference theAudio.

Unless, I don't understand what it is you are trying to do exactly. Seems like you keep changing the conditions as we continue this conversation.

I'll ask again then: what basic debugging have you done? You know, things like setting breakpoints and stepping through code. Or even NSLogs. Part of basic debugging is verifying that what you think is happening at each step is actually happening. Using skills like this is very key to troubleshooting.

And the reason I'm pushing so hard on this stuff is that if you look at your code for switchValueChanged, you may notice that it doesn't even reference theAudio.

Unless, I don't understand what it is you are trying to do exactly. Seems like you keep changing the conditions as we continue this conversation.

Click to expand...

I understand what you mean, ive tested this code on just a 2 view application and it stops the sound effects fine, its just when i add the 3rd view which is the actual game where it doesnt work anymore.

What makes you say that's the problem? You're still being awfully light on details.

Click to expand...

I know ive only been programming about 6 weeks, ive stripped the code back to how it was. So ive put the sound effect in an animate ball method on the gameview and have the audio declared in the .h (i dont have a property for it though)

Staff Member

I'm sorry but I'm afraid I can't help you anymore. You refrain from answering my simple questions and just keep posting code that shows no attempts to debug or provide any information on what debugging you've actually done. I'm out.

I'm sorry but I'm afraid I can't help you anymore. You refrain from answering my simple questions and just keep posting code that shows no attempts to debug or provide any information on what debugging you've actually done. I'm out.

Click to expand...

Sorry forgot to update this, i was getting way out of my depth so what ive done is just add background music throughout the whole of the application.

I can control that through the settings page, i understand how that works this other way was just tying me up in knots.

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.