The idea of my app is the user is asked a question via a label, they then type the answer into a text box and presses a button. if they get the answer wrong three times, an "i give up" button becomes active and they can click it to show the answer
showAnswer is linked to a button
nextQuestion is linked to a button
secondQuestion is linked to a view controller
When the nextQuestion button is pressed, the text box is set to yes and the next view is shown. Why does it do this???
Any help greatly appreciated.
Thanks in advance
The only possibility that I see is that you've got your nextQuestion button connected to BOTH showAnswer AND nextQuestion. Did you, by any chance, first connect the button accidentally to showAnswer and then try to correct it by connecting the button to nextQuestion? If so, you might have thought the second connection erases the first one, but instead, it just told the button to call BOTH methods.
You're going to want to go to the connections tab of the nextQuestion button, and under "events", find where it says something like "Multiple", click the little "x" button there, and reconnect it to only the nextQuestion method.
Logically (assuming IB was set up correctly), your code works, so if this doesn't do it, it has to be something with IB (or otherwise something outside the scope of this code). In that case try deleting both buttons and recreating and reconnecting them from scratch.
__________________
HEY! Was this post helpful?
If so, it would be MUCH appreciated if you'd just click on one of these apps:
MyD
Take 1 minute to set up your MyD and you'll always be able to prove you own your device!
Membrik
Test your memory by sliding tiles to match chains of increasing difficulty.
The only possibility that I see is that you've got your nextQuestion button connected to BOTH showAnswer AND nextQuestion. Did you, by any chance, first connect the button accidentally to showAnswer and then try to correct it by connecting the button to nextQuestion? If so, you might have thought the second connection erases the first one, but instead, it just told the button to call BOTH methods.
You're going to want to go to the connections tab of the nextQuestion button, and under "events", find where it says something like "Multiple", click the little "x" button there, and reconnect it to only the nextQuestion method.
Logically (assuming IB was set up correctly), your code works, so if this doesn't do it, it has to be something with IB (or otherwise something outside the scope of this code). In that case try deleting both buttons and recreating and reconnecting them from scratch.
The enter button was only connected to nextQuestion but i deleted both buttons and re-linked them but it still doesn't work
first off, == is the logic statement operand, not =. But saying =, you are actually setting the text to @"yes" and that is why that happens. However, to compare two nsstrings, you need to use the isEqualToString method. So your new if statemtent would look like:
first off, == is the logic statement operand, not =. But saying =, you are actually setting the text to @"yes" and that is why that happens. However, to compare two nsstrings, you need to use the isEqualToString method. So your new if statemtent would look like:
if ([answer.text isEqualTo:@"yes") {
//do stuff
}
Ah! I can't believe I missed that! Sorry OP >_<
__________________
HEY! Was this post helpful?
If so, it would be MUCH appreciated if you'd just click on one of these apps:
MyD
Take 1 minute to set up your MyD and you'll always be able to prove you own your device!
Membrik
Test your memory by sliding tiles to match chains of increasing difficulty.