NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

Milestone: Project 4-6 basic logic

Forums > 100 Days of SwiftUI

Hi everyone, i have a problem with this milestone, i don't have any idea how to do this -> You should generate all your questions as soon as your game starts, storing them as an array of questions. Those questions should probably be their own Swift struct, Question, storing the text and the answer. Could you help me to start write this code?

   

Hey, sorry it took so long to get to this.

So a simple struct would have the first number, the second number, and the answer, all of which would be ints.

You can't really generate them until the user's picked the range of what they want a quiz on. So when they press that button, you'd generate the answers at that point.

If you look at projects 4-6, all the building blocks are there. I just don't want to give you too much of the answer as the struggle's what helps us remember later on.

   

Hacking with Swift is sponsored by Judo

SPONSORED Let’s face it, SwiftUI previews are limited, slow, and painful. Judo takes a different approach to building visually—think Interface Builder for SwiftUI. Build your interface in a completely visual canvas, then drag and drop into your Xcode project and wire up button clicks to custom code. Download the Mac App and start your free trial today!

Try now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.