0

I am making a quiz game where I randomly load items from an array of questions into an array for answering. I use this code for that:

[self.questions addObject:self.allQuestions[(int)floor(arc4random() % [self.allQuestions count])]];

This works fine. It does not, however, remove them once it is done. Converting it to this:

    YNQuestion *q = self.allQuestions[(int)floor(arc4random() % [self.allQuestions count])];
    [self.questions addObject:q];
    [self.allQuestions removeObject:q];

And I get an EXC_ARITHMETIC error. I have no idea why, either.

This is in a loop that performs this 25 times. Later, it randomly fixed itself. I still would like to know origin of the bug, though.

4

0 回答 0