Small quibble on Quiz application


#1

Did anyone notice/does anyone care that Quiz starts up with the second question, not the first? That is because when showQuestion is called, it increments currentQuestionIndex at the top of the method, before a question is displayed. One way to fix this is to initialize currentQuestionIndex to -1 back in initWithNibName:bundle: where the other setup work is done. That makes me more comfortable anyway as I don’t like to depend on automatic initialization of variables. Another option might be to move the increment and check past last question code past the display code.


#2

OK, outsmarted myself a bit on that, if you use the -1 solution you get a nice crash if you tap “Show Answer” before show a question. Fixed that with a little error checking code in showAnswer. Let’s call that a “learning experience”.