Limiting the number of questions for an indexpath

Hey there, pretty new to coding with swift but I have a quiz app which has about 100 questions in an index path, and want the game to end at say 30 questions, any way I could do this? Any help would be greatly appreciated
Answered by tomdotcom12 in 667140022
Yep it was for a tabView, makes complete sense now that I look at that, saved the day cheers mate I owe you one!

about 100 questions in an index path

What do you mean, in a tabView ?

want the game to end at say 30 questions,

So, just create a property in the class
Code Block
var questionsAsked = 0

Each time you ask a question, increment it by 1
Code Block
questionsAsked += 1

And before asking a new question, test
Code Block
if questionsAsked >= 30 {
// alert user that game is over
}

If that answers your question, don't forget to close the thread by marking the correct answer, otherwise, please explain more your problem.
Accepted Answer
Yep it was for a tabView, makes complete sense now that I look at that, saved the day cheers mate I owe you one!
You should have marked the correct answer, not your comment.

Yep.

Note: TabView don't have indexPath. But TableView have.
Limiting the number of questions for an indexpath
 
 
Q