Author: Yuying Fan
Please leave feedback by posting on Ed or contacting the course staff.
Required Software: macOS Ventura, Xcode 15
Deadline: Thursday, 10/10 @ 11:59 PM
This assignment does not have any starter code -- you'll be creating your own project from scratch.
In this assignment, you will create a trivia game application using SwiftUI. This project will consolidate your understanding of UI components, state management, navigation, and app design by applying them to a real-world interactive application. We have laid out some basic requirements and a high-level guide to get you started, but the design and implementation are up to you. Pick your favorite trivia topic and have fun!
Your app should have at least three screens:
Your game should have at least 5 questions, each with question text, an image, and 4 answer options. (The image can be an SF Symbols icon if you'd like.) The game should track the user's score as they progress through the questions (the exact scoring system is up to you, so long as each question affects it).
You should use the Model-View-ViewModel (MVVM) architecture to separate the game logic from the UI:
Question
model that represents a single question.QuizViewModel
that manages the game state.You should also use these SwiftUI features:
ObservableObject
for the view model (or @Observable
)@Binding
to pass simple data between viewsNavigationStack
and NavigationLink
for screen transitionsThe above are simply some minimum requirements for us to grade your game. We encourage you to add more features and polish your game as much as you like!
This assignment is out of 100 points, with the following breakdown:
Note: The Welcome Screen can be split into two screens if you choose to have a separate instructions screen.
Text
, Image
, Button
, and layout components across all screens (3
points each, 12 points total)@Binding
to pass data to a child or sibling view (5 points)If you're using ObservableObject
:
ObservableObject
for managing the game state, with @Published
properties (10 points)@StateObject
and/or @ObservedObject
(or @EnvironmentObject
) in views to observe the game state changes (5 points)If you're using @Observable
:
@Observable
object for managing the game state (10 points)@State
or @Environment
in views to observe the game state changes (5 points)NavigationStack
for smooth screen transitions (5 points)Question
model representing each question (5 points)QuizViewModel
managing game logic and state, with appropriate
encapsulation of game logic and separation of concerns (10 points)Picker
to select the difficulty level of the quiz, or a Slider
to adjust the volume of the sound effects.The exact implementation is up to you, and we in fact recommend you take some time to sketch out how you personally might want to structure your app on paper or a whiteboard. This will help you more easily reason about your code later on.
We've provided a basic guide to get you started, but feel free to disregard it entirely:
View Guide →To submit your homework, zip (or tar.gz) of your entire XCode project folder and upload it to Gradescope. Make sure that you've given the requirements another read before you do so.
Submit on Gradescope →